|
Posted by Martin Mandl - m2m tech support on 03/10/07 15:59
On Mar 10, 12:02 am, "mpar612" <mpar...@gmail.com> wrote:
> 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>";
>
> }
>
> ?>
Dear mpar612,
put your error messages in a string instead of printing directly, and
print them when and where you want to have them ...
good luck
Martin
------------------------------------------------
online accounting on bash bases
Online Einnahmen-Ausgaben-Rechnung
http://www.ea-geier.at
------------------------------------------------
m2m server software gmbh
http://www.m2m.at
Navigation:
[Reply to this message]
|