我收到一条错误消息:注意:未定义变量:在第 4 行提交。我不知道为什么,因为我已经使用提交按钮定义了它?有人可以解释为什么吗?真的看不出这里的问题。
<?php
if($submit)
{
$sql = "INSERT INTO personnel (first, last, username, department, email) VALUES ('$first','$last','$username','$department','$email')";
$add = mysql_query($sql);
echo "<div class='confirmation-box round'>Thank you! New user have been added</div>";
}
else
{
?>
<form method="post" action="useradd.php">
<fieldset>
<p>
<label for="simple-input">Firstname</label>
<input type="text" id="first" name="firstname" class="round default-width-input" />
</p>
<p>
<label for="simple-input">Lastname</label>
<input type="text" id="last" name="lastname" class="round default-width-input" />
</p>
<p>
<label for="simple-input">Username</label>
<input type="text" id="username" name="username" class="round default-width-input" />
</p>
<p>
<label for="simple-input">Department</label>
<input type="text" id="department" name="department" class="round default-width-input" />
</p>
<p>
<label for="simple-input">Email</label>
<input type="text" id="email" name="email" class="round default-width-input" />
</p>
<input type="Submit" name="submit" class="button round blue image-right ic-add text-upper" value="Add">
</fieldset>
</form>
<?php
}
?>
(对不起愚蠢的问题,有点新的PHP)