我无法在我的代码中的文本框之后放置这个 astrik(*)。其次,我的表单显示为向下。我无法找出问题所在。请你帮帮我。请尝试提供更多尽快解释。
<style>
.error {color: #FF0000;}
</style>
<?php
$firstnameErr = $lastnameErr = $emailErr = "";
$firstname = $lastname = $email = "";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (empty($_POST["firstname"]))
{$firstnameErr = "Name is required";}
else
{
$firstname = test_input($_POST["firstname"]);
}
if (empty($_POST["lastname"]))
{$lastnameErr = "Name is required";}
else
{
$lastname = test_input($_POST["lastname"]);
}
if (empty($_POST["email"]))
{$emailErr = "Email is required";}
else
{
$email = test_input($_POST["email"]);
}
}
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<div text align =center><h1>Eventous Info</h1></div>
<h3>Fill the Required Form:</h3>
<p><span class="error">*required field</span></p>
<table>
<form action="insert.php" method="post">
<tr>
<td>Firstname</td><td>:</td> <td><input type="text" name="firstname" >
</td>
<span class="error">* <?php echo $firstnameErr;?></span><br><br>
</tr>
<tr>
<td>Lastname</td><td>:</td><td><input type="text" name="lastname" ></td>
<span class="error">* <?php echo $lastnameErr;?></span><br><br>
</tr>
<tr>
<td>Email</td><td>:</td><td><input type="text" name="email"></td>
<span class="error">* <?php echo $emailErr;?></span><br><br>
</tr>
<tr>
<td>Phone</td><td>:</td><td><input type="text" name="number"><td><br><br>
</tr>
</table>
<input type="submit" >
</form>`