Web Hosting Talk







View Full Version : PHP Mail Error


smartsoft
07-13-2007, 10:38 PM
<?php
// Receiving variables
@$fname = addslashes($_POST['fname']);
@$lname = addslashes($_POST['lname']);
@$phone = addslashes($_POST['phone']);
@$city = addslashes($_POST['city']);
@$state = addslashes($_POST['state']);
@$country = addslashes($_POST['country']);
@$email = addslashes($_POST['email']);
@$user = addslashes($_POST['user']);
@$pass = addslashes($_POST['pass']);
@$domain = addslashes($_POST['domain']);
@$select = addslashes($_POST['select']);
@$website_package = addslashes($_POST['website_package']);
@$website_hosting = addslashes($_POST['website_hosting']);
@$payment_method = addslashes($_POST['payment_method']);
@$agreement = addslashes($_POST['agreement']);
// Validation
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
echo "You email is invalid please hit the back butto to go back";
exit;
}
//Sending Email to form owner
# Email to Owner
$header = "From: $email";
$subject = "Someone has made an order";
// Change to your email address.........
$emailto = "hme@atmysite.com";
$message = "fname: $fname\n"
. "lname: $lname\n"
. "addr: $adddr\n"
. "phone: $phone\n"
. "city: $city\n"
. "state: $state\n"
. "country: $country\n"
. "email: $email\n"
. "user: $user\n"
. "pass: $pass\n"
. "domain: $domain\n"
. "website_package: $website_package\n"
. "website_hosting: $website_hosting\n"
. "payment_method: $payment_method\n"
. "agreement: $agreement\n"
. "\n"
mail($to, $subject ,$message ,$header ) ;
header("location:thankyou.php");
?>


i don't understand it get on telling me error at my mail() whatever please someone look at it and tell me what is wrong pls. thank you.

foobic
07-13-2007, 11:31 PM
. "\n";
mail($to, $subject ,$message ,$header ) ;
header("location:thankyou.php");
?>
For future reference, if you post the actual error message as well as the code you're more likely to get a quick answer.

smartsoft
07-13-2007, 11:58 PM
Thank you Foobic, this is the error code i got

Parse error: syntax error, unexpected T_VARIABLE in /home/smartsof/public_html/web/sendorder.php on line 74

BurakUeda
07-14-2007, 12:14 AM
Thank you Foobic, this is the error code i got

Parse error: syntax error, unexpected T_VARIABLE in /home/smartsof/public_html/web/sendorder.php on line 74
And there is now way for us to know what is in line 74.

smartsoft
07-14-2007, 12:38 AM
this is the line

74. mail($to, $subject ,$message ,$header ) ;

You can test run the code and see what it says

foobic
07-14-2007, 12:55 AM
Did you fix the missing semicolon on the preceding line?

smartsoft
07-14-2007, 02:07 AM
Yah man it work fine thanks man, but another problem the mail entered my box quite alright but it doesn't show them my thank you page. instead it shows blank page and when i check my box, i can see the mail in my box.

header("location:thankyou.php");

i would love to chat with ya on Yahoo. my Id is smartsoftlimited

So do look at that error for me please

smartsoft
07-14-2007, 02:24 AM
Hey finally it went through to my box and showing me my thank you page. foobic pls drop your yahoo id, so we could know more pleaseeeeeee.

horizon
07-14-2007, 07:37 AM
Hi, I like this. Althought, if I may just recommend this block instead:


<?php
// Receiving variables
@$fname = (isset($_POST['fname'])) ? (stripslashes(trim($_POST['fname']))) : "";
@$lname = (isset($_POST['lname'])) ? (stripslashes(trim($_POST['lname']))) : "";
@$phone = (isset($_POST['phone'])) ? (stripslashes(trim($_POST['phone']) : "";
@$city = (isset($_POST['city'])) ? (stripslashes(trim($_POST['city']))) : "";
@$state = (isset($_POST['state'])) ? (stripslashes(trim($_POST['state']))) : "";
@$country = (isset($_POST['country'])) ? (stripslashes(trim($_POST['country']))) : "";
@$email = (isset($_POST['email'])) ? (stripslashes(trim($_POST['email']) : "";
@$user = (isset($_POST['user'])) ? (stripslashes(trim($_POST['user']))) : "";
@$pass = (isset($_POST['pass'])) ? (stripslashes(trim($_POST['pass']))) : "";
@$domain = (isset($_POST['domain'])) ? (stripslashes(trim($_POST['domain']))) : "";
@$select = (isset($_POST['select'])) ? (stripslashes(trim($_POST['select']))) : "";
@$website_package = (isset($_POST['website_package'])) ? (stripslashes(trim($_POST['website_package']))) : "";
@$website_hosting = (isset($_POST['website_hosting'])) ? (stripslashes(trim($_POST['website_hosting']))) : "";
@$payment_method = (isset($_POST['payment_method'])) ? (stripslashes(trim($_POST['payment_method']))) : "";
@$agreement = (isset($_POST['agreement'])) ? (stripslashes(trim($_POST['agreement']))) : "";

// Validation for license agreement.
if (isset($agreement) && empty($agreement))
{
echo "You did not agreed to the terms before submitting the form. Please hit the back button to go back and try again.";
exit;
}

// Validation for first name.
if (isset($fname) && empty($fname) || !ereg('[A-Za-z\-]', $fname))
{
echo "Your first name is either empty or does not valid characters. Please hit the back button and try again.";
exit;
}

// Validation for last name.
if (isset($lname) && empty($lname) || !ereg('[A-Za-z\-]', $lname))
{
echo "Your last name is either empty or does not valid characters. Please hit the back button and try again.";
exit;
}

// Validation for phone number.
if (isset($phone) && empty($phone) || !ereg('[0-9\-]', $phone))
{
echo "Your phone number is either empty or does not match valid values. Please hit the back button and try again.";
exit;
}

// Validation for city.
if (isset($city) && empty($city) || !ereg('[A-Za-z\-]', $city))
{
echo "Your city entry is either empty or does not valid characters. Please hit the back button and try again.";
exit;
}

// Validation for state.
if (isset($state) && empty($state) || !ereg('[A-Za-z\-]', $state))
{
echo "Your state entry is either empty or does not valid characters. Please hit the back button and try again.";
exit;
}

// Validation for country.
if (isset($country) && empty($country) || !ereg('[A-Za-z\-]', $country))
{
echo "Your country entry is either empty or does not valid characters. Please hit the back button and try again.";
exit;
}

// Validation for usernames.
if (isset($user) && empty($user) || !ereg('[A-Za-z\-\_]', $user))
{
echo "Your username is either empty or does not valid characters. Please hit the back button and try again.";
exit;
}

// Validation for passwords.
if (isset($pass) && empty($pass) || !ereg('[A-Za-z\-\_]', $pass))
{
echo "Your password is either empty or does not valid characters. Please hit the back button and try again.";
exit;
}

// Validation for domain names.
if (isset($domain) && empty($domain) || !preg_match('@^(?:http://)?([^/]+)@i', $domain)) {
echo "Your domain name has not been correctly stated. Please hit the back button and try again.";
exit;
}

// Validation for selections.
if (isset($select) && empty($select)) {
echo "Your selection entry is empty. Please hit the back button and try again.";
exit;
}

// Not quite sure about the packages and hosting question ...

// Validation for payment method.
if (isset($payment_method) && empty($payment_method) || !ereg('[A-Za-z0-9\-\_]', $payment_method)) {
echo "Your payment method option is either empty or invalid. Please hit the back button and try again.";
exit;
}

// Validation for emails
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
echo "Your email is invalid please hit the back button to go back";
exit;
}

//Sending Email to form owner
# Email to Owner
$header = "From: " . $email;
$subject = "Someone has made an order";
// Change to your email address.........
$emailto = "hme@atmysite.com";
$message = "fname: " . $fname . "\n"
. "lname: " . $lname . "\n"
. "addr: " . $adddr . "\n"
. "phone: " . $phone . "\n"
. "city: " . $city . "\n"
. "state: " . $state . "\n"
. "country: " . $country . "\n"
. "email: " . $email . "\n"
. "user: " . $user . "\n"
. "pass: " . $pass . "\n"
. "domain: " . $domain . "\n"
. "website_package: " . $website_package . "\n"
. "website_hosting: " . $website_hosting . "\n"
. "payment_method: " . $payment_method . "\n"
. "agreement: " . $agreement . "\n"
. "\n"
mail(stripslashes(trim($emailto)), stripslashes($subject), strip_tags($message), $header);

unset ($emailto);
unset ($subject);
unset ($message);
unset ($header);

header("location:thankyou.php");
?>


;)