Hi,
How and can the following HTML (Form) and PHP code be merged into one file?
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<form name="form1" id="form1" method="post" action="login.php">
<label>ID:</label>
<input name="id" type="text" id="id" />
<br />
<br />
<input name="save" type="submit" id="save" value="Save" />
</form>
</body>
</html>
PHP
<?php
session_start();
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die(mysql_error());
}
mysql_select_db("db", $con);
$id = mysql_real_escape_string($_POST['id']);
$data = mysql_query("SELECT * FROM users WHERE id='$id'");
$row = mysql_fetch_array($data);
if(!mysql_num_rows($data)==0)
{
$_SESSION['token'] = 1;
$_SESSION['user'] = $row['name'];
$_SESSION['account'] = $row['account'];
header("location: userpage.php");
exit();
}
else
{
echo "Login Unsuccessful!";
}
mysql_close($con);
?>