Pages

Tuesday, January 10, 2012

How to create a form in PHP

coding: form.php

<html>
<body>

<form action="welcome.php" method="post">
Name: <input type="text" name="fname" /><br/>
Age: <input type="text" name="age" /><br/>
      <input type="submit" />
</form>

</body>
</html>

welcome.php

<html>
<body>

Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years old.

</body>
</html>

The output is:




Tuesday, January 3, 2012

php code for daily notification

<html>
<body>
<?php
$today = date("l");
print("$today");
if($today == "Sunday")
{
$bgcolor = "#ffffff";
}
elseif($today == "Monday")
{
$bgcolor = "#ffff00";
}
elseif($today == "Tuesday")
{
$bgcolor = "126nh";
}
elseif($today == "Wednesday")
{
$bgcolor = "#00ffff";
}
elseif($today == "Thursday")
{
$bgcolor = "#ff0000";
}
elseif($today == "Friday")
{
$bgcolor = "#00ff00";
}
else
{ // Only Saturday remains
$bgcolor = "#0000ff";
}
print("<body bgcolor=\"$bgcolor\">\n");
?>
</body>
</html>