Free Web Hosting Forum
(#1 (permalink))
Old
Member
stannwl is on a distinguished road
 
Posts: 38
Join Date: May 2012
Default Alignment Issue - 05-15-2012, 05:38 PM

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;
}
}
}
?>
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 762
Join Date: Dec 2010
Default 05-15-2012, 11:29 PM

If you have "error" class in your css file, how about adding vertical-align as shown in the following example?

p.error {
color: red;
vertical-align: top/middle/bottom
/*text-transform: uppercase;*/
}

Or

<span class="error" valign="top/middle/bottom"><?php echo $nameErr;?></span>

Last edited by grace1004; 05-16-2012 at 03:24 AM.
Reply With Quote
(#3 (permalink))
Old
Member
stannwl is on a distinguished road
 
Posts: 38
Join Date: May 2012
Default 05-16-2012, 08:03 AM

Hi Grace1004,

Thanks for your help. I've tried both method and seems like the 2nd one couldn't solve the problem.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com