Refer this introduction , before doing any PHP program.
PHP Introduction - And some useful points in Programming
PHP Introduction - And some useful points in Programming
- Open Dreamweaver to write php code , with in the body tag .That is ,
.......................} php code
</body> .
and save it (as .php) under the www directory of wamp server.
- Then click wamp-->localhost to view it in the browser.
=================================================================
A : Creatng the form :
B : Odd/Even checking code :
A & B : The total code is ;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
if(isset($_GET["c"]))
{
$re=null;
$a=$_GET['name'];
if(isset($a) && is_numeric($a))
{
if ($a%2==0)
{
$re="Even number";
}else
{
$re="Odd number";
}
}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" METHOD="get">
Enter a number <input type='text' name ='name' value="<?php if(isset($a)){ echo $a;} ?>"/>
<?php
if(isset($re))
{
echo $re;
}
?><br />
<input type="submit" value="Check" name="c"/>
</form>
</body>
</html>
(Blue color is the first part (A) of the code , and brown color is the B part.
C : Result:
1 comment:
hai
gud blog
Post a Comment