我试图创建一个数据库,一旦按下提交按钮就存储值,但我得到了:
“注意:未定义的索引:第 10 行 C:\xampp\htdocs\WebSite\examp.php 中的提交”阻止我的程序执行这是我的网页:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Dance </title>
</head>
<body>
<h1>Record examination performance</h1>
<form method=post" action="examp.php">
<dl>
<dt>Man. (Email of student dancing male steps) </dt>
<dd><input type = "text" name="hemail" /></dd>
<dt>Woman. (dances female steps) </dt>
<dd><input type="text" name="shemail"/ >
</dl>
<dt>Date of examination </dt>
<dd><input type="text" name="date" /></dd>
<dt>Style</dt>
<dd>
<select name="style" size="4">
<option value="BL">Ballroom</option>
<option value="LT">Latin American</option>
</select>
</dd>
<dt>Level</dt>
<dd>
<select name="level">
<option value="bronze">Bronze</option>
<option value="silver">Silver</option>
<option value="gold">Gold</option>
</select>
</dd>
<dt>Mark</dt>
<dd><input type="number" name="mark" />
<dd>
<p>
<button value="press " name="SUBMIT">Submit</button>
<button name="Clear" type="reset">Reset</button>
</p>
</form>
</body>
</html>
这是我的程序:
<?php
$connect=mysql_connect("localhost", "user", "");
if(!$connect){
die("Failed to connect: " . mysql_error());
}
else if(!mysql_select_db("studentdatabase")){
die("Failed to connect to a database" . mysql_error());
}
else{
if($_POST['SUBMIT']){
$man=$_POST['hemail'];
$woman=$_POST['shemail'];
if($man==$woman ||!$man || !$woman){
echo "There is no parner! ";
die("Nothing is added");
mysql_close($connect);
}else {
$date=$_POST["date"];
}
}
}
?>
所以这意味着在 $_POST 但是当我改变它 $_GET 它开始工作。在我编写的其他程序中的其他变量 $woman、$man 等中也是如此,但在这里...有帮助吗?提前致谢!