Sunday, November 9, 2014

A simple PHP

This is the PHP program that I did successfully for the first time.

<html>
<head>
<title>
This is an php tutorial
</title>
</head>
<body>
<form action="learnphp.php" method="post">
<table border="0">
<tr>
<td>Name</td>
<td align="center"><input type="text" name="username" size="30" /></td>
</tr>
<tr>
<td>Address</td>
<td align="center"><input type="text" name="streetaddress" size="30" /></td>
</tr>
<tr>
<td>City</td>
<td align="center"><input type="text" name="cityaddress" size="30" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
view raw enterinfo.html hosted with ❤ by GitHub
<html>
<head>
<title>Information Gathered</title>
</head>
<body>
<?php
define('PI', 3.14);
echo "The value of PI is" . PI;
echo "</br> 5 + 2 =" . (5 + 2);
echo "</br> 5 - 2 =" . (5 - 2);
echo "</br> 5 * 2 =" . (5 * 2);
echo "</br> 5 / 2 =" . (integer)(5 / 2);
echo "</br> 5 % 2 =" . (5 % 2);
$usersName=$_POST['username'];
$streetAddress=$_POST['streetaddress'];
$cityAddress=$_POST['cityaddress'];
echo $usersName . "</br>";
echo $streetAddress . "</br>";
echo $cityAddress . "</br>";
$str = <<<EOD
The coustomer name is $usersName and he lives in $streetAddress at $cityAddress </br>
EOD;
echo $str;
?>
</body>
</html>
view raw learnphp.php hosted with ❤ by GitHub

No comments:

Post a Comment