<!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>
<form id="form1" name="form1" method="post" action="admin page.php">
<p>
<label for="Name">Name</label>
<input type="text" name="Name" id="Name" />
</p>
<p>
<label for="Age">Age </label>
<input type="text" name="Age" id="Age" />
</p>
<p>
<label for="Email">Email</label>
<input type="text" name="Email" id="Email" />
</p>
<p>
<label for="DOB">DOB</label>
<input type="text" name="DOB" id="DOB" />
</p>
<p>
<input type="button" name="add" id="add" value="Add" onclick="func();" />
</p>
</form>
<?php
function func()
{
$con = mysql_connect("127.0.0.1","root","") or die(mysql_error());
$db = mysql_select_db("lr") or die(mysql_error());
$sql=mysqli_query("INSERT INTO Persons (Name,age,Email,DOB)
VALUES ('&Name', '&Age','&Email','&DOB')");
if($sql){echo "Welcome ".$Name.",you may Login now! ";}
mysql_close($con);
}
?>
</body>
这是我想在同一页面上运行查询的代码!我无法在其他页面上执行此操作,因为我想在此页面中递归添加用户。我在单击时调用了函数 func 来执行此操作,但它不起作用。