You are here: Placing Errors On The Page « PHP Programming Language « IT news, forums, messages
Placing Errors On The Page

Posted by mpar612 on 03/09/07 23:02

I have code below (due to length I only included a portion). I am
validating an email address. It checks to see if the email field is
blank, in the proper format, etc... It prints errors to the screen and
everything works perfectly, but the errors always print at the very
top of the page and I am having difficulty moving those errors around
so they fit nicely into the page design I have. Rather than printing
the errors I tried assigning them to variables and printing them
elsewhere on the page, but it didn't work and the errors did not try
at all. I also tried moving the function to a different part of the
page where the errors would print where I wanted them, but I had the
same problem as with the variables. I'm kind of in a bind and need
this done asap. Does anyone have any thoughts on this?

Thanks in advance!!!

<?php
function process_form() {

global $db;

$firstName = addslashes($_POST['firstName']);
$lastName = addslashes($_POST['lastName']);
$email = $_POST['email'];
$emailHash = md5($email);
$active = "n";

// Check syntax
$validEmailExpr = "^[0-9a-z~!#$%&_-]([.]?[0-9a-z~!#$
%&_-])*" .
"@[0-9a-z~!#$%&_-]([.]?[0-9a-z~!#$%&_-])*
$";

// Validate the email
if (empty($email))
{
print "The email field cannot be blank";
return false;
}
elseif (!eregi($validEmailExpr, $email))
{
print "The email must be in the name@domain format.";
return false;
}
elseif (strlen($email) > 30)
{
print "The email address can be no longer than 30
characters.";
return false;
}
elseif (function_exists("getmxrr") &&
function_exists("gethostbyname"))
{
// Extract the domain of the email address
$maildomain = substr(strstr($email, '@'), 1);

if (!(getmxrr($maildomain, $temp) ||
gethostbyname($maildomain) != $maildomain))
{
print "The domain does not exist.";
return false;
}
}

$db->query('INSERT INTO users (firstName, lastName, email, hash,
active)
VALUES (?,?,?,?,?)',
array($firstName, $lastName, $email, $emailHash,
$active));

$message = "
Thank you for signing up for the . Please click on the link below
to confirm your registration. If the link is not active, copy-and-
paste it into your browser window.

http://www.EmailCapture/validateSuccess.php?id=$emailHash
";

$subject = "";
$from = "";

mail("$email", "$subject", "$message", "From: $from");

print "<script>window.location='ThankYou.htm'</script>";

}
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация