Page 1 of 1

[SOLVED] Validation help

Posted: Wed Aug 11, 2004 5:41 am
by Dream

Code: Select all

<div class="header">Hosting Order Form</div>
<div class="storycontent">
<?php
//Perform Form Validation Here
if (!$name || !$country || !$email || !$plan || !$frontpage || !$domain || !$username || !$pwd ||
!$pwd2 || !$payment || !$term || !$paypalmail)
{
echo "You didn't fill in all the required fields. Go back.";
}
else {

//do email format validation
if(!eregi('^([._a-z0-9-]+[._a-z0-9-]*)@(([a-z0-9-]+\.)*([a-z0-9-]+)(\.[a-z]{2,3})?)$', $email))
{
echo "This is not a valid email address. Go back";
}
else {

//do password validation
if ($pwd != $pwd2)
{
echo "Your password didn''t match. Go back"; 
exit;
}

// Ok, now send email
$myemail = "removed";
$headers = "From: "$name" <$email>\n";
$message = "
Full Name: $name
Country: $country
Email: $email

Hosting Plan: $plan
Frontpage Extension: $frontpage
Domain name: $domain

Username: $username
Password: $pwd

Payment Method: $payment
Term of Payment: $term

Paypal Email: $paypalmail
";

mail("$myemail", "Decorum Hosting Order Form", $message, $headers);

echo "Thank you <b>$name</b>, your order has been sent. <br />
<br />
Your order will be processed within 24 hours. <br />
Billing information will be sent to your email address (<b>$email</b>) where you can make payment for your account. <br />
Upon receiving payment your account access information will be emailed directly to you.";

}
?>

</div>
This gives an parse error on line 58 (which is the last "</div>" statement, I'm sure it is a logical explaination for this, its just I cant seem to see it hehe.

The form validation works well if I comment away the

Code: Select all

}
else {

//do password validation
if ($pwd != $pwd2)
{
echo "Your password didn''t match. Go back";
part

Its seems like this is messing up my validation.

I was woundering if anyone out there could help me with a solution on how to make it check that $pwd and $pwd2 are equal (I ask the users to type his password twice for validation and to prevent misspelling of the password


Thanks for you help on advance =)

Posted: Wed Aug 11, 2004 6:27 am
by Skittlewidth
I think you are missing a closing bracket for your first else statement, but I've only had a quick look. Thats what usally causes me errors on lines that don't appear to have php on them!

Posted: Wed Aug 11, 2004 6:36 am
by Dream
Found my error, was kind of an logical error hehe.. and it got tweaked alittle so now it works as it should

Solution:

Code: Select all

//Perform Form Validation Here
if (!$name || !$country || !$email || !$plan || !$frontpage || !$domain || !$username || !$pwd ||
!$pwd2 || !$payment || !$term)
{
        echo "You didn't fill in all the required fields. Go back.";
}
//do email format validation
elseif (!eregi('^([._a-z0-9-]+[._a-z0-9-]*)@(([a-z0-9-]+\.)*([a-z0-9-]+)(\.[a-z]{2,3})?)$', $email))
{
        echo "This is not a valid email address. Go back";
}
//confirm password
elseif ($pwd != $pwd2)
{
        echo "Your password didnt match. Go back";
        exit;
}
Thanks for your help guys =)