Hi All,
I'm writing a code which will display "Missing" beside the text input area. I've gotten the code up and running, but the problem is that the word "Missing" is not in line with the text input area. It's lower than then text box.
My website is @
http://www.stannwl.site90.net/contact.php
Is there anyway i can align it? Below is the html and php code
<form name="contact" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<label for="name">Name:</label>
<input type="text" name="name" value="<?php echo htmlspecialchars($name);?>">
<span class="error"><?php echo $nameErr;?></span>
<label for="tel">Telephone:</label>
<input type="text" name="tel" value="<?php echo htmlspecialchars($tel);?>">
<span class="error"><?php echo $telErr;?></span>
<label for="email">E-mail:</label>
<input type="text" name="email" value="<?php echo htmlspecialchars($email);?>">
<span class="error"><?php echo $emailErr;?></span>
<label for="subject">Subject:</label>
<input type="text" name="subject" value="<?php echo htmlspecialchars($subject);?>">
<span class="error"><?php echo $subjectErr;?></span>
<label for="comments">Comments:</label>
<textarea name="comments" value="<?php echo htmlspecialchars($comments);?>" cols="40" rows="10"></textarea>
<span class="error"><?php echo $commentsErr;?></span>
<br>
<br>
<input type="submit" name="submit" class="submit" value="Submit">
</form>
<?php
//define variables and initialize with empty values
$nameErr = $telErr = $emailErr = $subjectErr = $commentsErr = "";
$name = $tel = $email = $subject = $comments ="";
if($_SERVER["REQUEST_METHOD"] == "POST")
{
if(empty($_POST['name']))
{
$nameErr = "Missing";
}
else
{
$name = $_POST["name"];
}
if(empty($_POST['tel']))
{
$telErr = "Missing";
}
else
{
$tel = $_POST["tel"];
}
if(empty($_POST['email']))
{
$emailErr = "Missing";
}
else
{
$email = $_POST["email"];
}
if(empty($_POST['subject']))
{
$subjectErr = "Missing";
}
else
{
$subject = $_POST["subject"];
}
if(empty($_POST['comments']))
{
$commentsErr = "Missing";
}
else
{
$comments = $_POST["comments"];
}
if(empty($_POST['name']) || empty($_POST['tel']) || empty($_POST['email']) || empty($_POST['subject']) || empty($_POST['comments']))
{
$error = true;
}
else
{
$to = '$email';
$subject = '$subject';
$name = trim($_POST['name']);
$tel = trim($_POST['tel']);
$email = trim($_POST['email']);
$subject = trim($_POST['subject']);
$messages = trim($_POST['comments']);
$messages = "Name: $name \r\n Tel: $tel \r\n Email: $email \r\n Messages: $messages";
$headers = "From:" . $email;
$mailsent = mail($to, $subject, $messages, $headers);
if(mailsent)
{
$sent = true;
}
}
}
?>