Can php be embedded within html?
Is the following program correct?
[code=php]<html>
<head>
<title>add.php</title>
</head>
<body>
<form action=”add.php” method=”POST”>
Enter emp id: <input type=”text” name=”eid”><br>
Enter emp name: <input type=”text” name=”enm”><br>
Enter salary: <input type=”text” name=”sal”><br>
<input type=”submit” value=”Enter”><br>
</form>
<?php
extract($_REQUEST);
$con=mysql_connect(‘localhost’,’root’,”);
if(!$con)
{
die(“Error:”.mysql_error());
}
$db=mysql_select_db(‘db1’,$con)
or die(“error:”.mysql_error());
$sql=”insert into emp(emp_id,ename,salary) values(‘$eid’,’$enm’,’$sal’)”;
if(!mysql_query($sql,$con))
{
die(‘Error:’.mysql_error());
}
else
{
echo “Record Saved”;
}
?>
</body>
</html>