...

View Full Version : php email help



mindee
01-16-2010, 12:19 AM
Having problems with PHP code as I'm completely new to this and spent the last 24 hours odd to figure out where I'm going wrong, so any help would be greatly appreciated. I've been reading through a number of the posts on this forum but haven't found anything that specifically addresses the issues I'm facing here, totally frustrated so asking for some help from the experts here would be greatly appreciated.

I'm trying to take the data from a form (attached) to be emailed to me.

My current problem is this message "Parse error: syntax error, unexpected T_VARIABLE in /home/fmglobal/public_html/sendeail.php on line 73" but may find more on resolving this fault...

entire code is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
</head>
<body>

<?php

$_POST['fullname'];
$_POST['company-name'];
$_POST['limited'];
$_POST['partnership'];
$_POST['sole-trader'];
$_POST['VAT-reg'];
$_POST['birth_date1'];
$_POST['birth_date2'];
$_POST['birth_date3'];
$_POST['address'];
$_POST['country'];
$_POST['town'];
$_POST['postcode'];
$_POST['email'];
$_POST['phone_day'];
$_POST['phone_evening'];
$_POST['mobile'];
$_POST['account-name'];
$_POST['sort-code'];
$_POST['account-no'];
$_POST['accept1'];
$_POST['accept2'];
$_POST['accept3'];
$_POST['accept4'];
$_POST['accept5a'];
$_POST['accept5b'];
$_POST['accept6'];
$_POST['starter-code'];
$_POST['starter-order'];
$_POST['comments'];
$_POST['payment-method'];
$_POST['PayPal'];
$_POST['Money-Transfer'];
$_POST['Credit-Debit'];
$_POST['payment-email'];
$_POST['todayis'];
$_POST['message'];


if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$email == "" && (!strstr($email,"@") || !strstr($email,".")))
if(!$payment-email == "" && (!strstr($payment-email,"@") || !strstr($payment-email,".")))
{
echo "Use Back - Enter valid e-mail \n";
$badinput = "Feedback was NOT submitted \n";
echo $badinput;
die ("Go back! ! ");
}

if(empty($fullname) || empty($birth_date1) || empty($birth_date2) || empty($birth_date3) || empty($address) || empty($country) || empty($town) || empty($postcode) || empty($email) || empty($phone_day) || empty($accept1) || empty($accept2) || empty($accept3))
{
echo "Use Back - fill in all fields (*) \n";
die ("Use back! ! ");
}

$todayis = date("l, F j, Y, g:i a") ;

$subject = "New FM Global Team Sign Up"

$message = "$todayis [EST] \n
Full Name: $fullname \n
Company Name: $company-name \n
Company Type: $company \n
VAT Reg No: $VAT-reg \n
Birth Day: $birth_date1 \n
Birth Month: $birth_date2 \n
Birth Year: $birth_date3 \n
Address: $address \n
Town: $town \n
Postcode: $postcode \n
Country: $country \n
Email: $email \n
Phone (Day): $phone_day \n
Phone (Evening): $phone_evening \n
Cell/Mobile Phone: $mobile \n
Bank Account Name: $account-name \n
Bank Sort Code: $sort-code \n
Bank Account Number: $account-no \n
Agrees Data Held by FM Cosmetics: $accept1 \n
Applies for FM Distributorship: $accept2 \n
Accepts Terms & Conditions: $accept3 \n
Wants a 49.99 Starter Pack: $accept4 \n
Wants a 42.50 Starter Pack: $accept5a \n
Wants a 24.50 Starter Pack: $accept5b \n
Confirms possession of Starter Pack: $accept6 \n
Start Pack Code: $starter-code \n
Initial Order: $starter-order \n
Additional Comments: $comments \n
Payment Method: $payment-method \n
Paypal Email: $payment-email \n
";


$from = "From: $email\r\n";


mail("dollop@hotmail.com", $subject, $message, $from);

?>

</body>
</html>


I also attach the form it populating from.

Thank you

Dormilich
01-16-2010, 12:55 AM
it would help to know, which line of your code line 73 is. nevertheless I suspect a missing concatenation operator.

tomws
01-16-2010, 02:20 AM
Please wrap your code in php tags. It's much easier to read. It also would have helped to spot the problem:

$subject = "New FM Global Team Sign Up"

You're missing a semicolon there.

Other problems:

$_POST['fullname'];
And so on. You need to assign these values to variables. As it is, they're not doing anything. It's equivalent to writing
$my_variable;
There's nothing happening. The obvious way to assign is like this:

$fullname = $_POST['fullname'];
There is another way to do it that's less obvious, but I'll let someone else confuse you with that.

Technically, if you're on an old version of PHP (or if your newer version is manually configured to handle it), variables are automatically created on a form handler page. However, PHP 5 (and the forthcoming 6) have this "feature" disabled because it is a security risk. So, even if your server allows the sloppy method, you would be better served by getting in the habit of handling the variables yourself.

mindee
01-16-2010, 02:07 PM
Please wrap your code in php tags. It's much easier to read. It also would have helped to spot the problem:

$subject = "New FM Global Team Sign Up"

You're missing a semicolon there.

Other problems:

$_POST['fullname'];
And so on. You need to assign these values to variables. As it is, they're not doing anything. It's equivalent to writing
$my_variable;
There's nothing happening. The obvious way to assign is like this:

$fullname = $_POST['fullname'];
There is another way to do it that's less obvious, but I'll let someone else confuse you with that.

Technically, if you're on an old version of PHP (or if your newer version is manually configured to handle it), variables are automatically created on a form handler page. However, PHP 5 (and the forthcoming 6) have this "feature" disabled because it is a security risk. So, even if your server allows the sloppy method, you would be better served by getting in the habit of handling the variables yourself.

Thank you TomWS

Missing semi colon did the trick

Also I was having a problem earlier when it was not allowing:
$fullname = $_POST['fullname'];
which isuspect had something to do with hypens in the '$full-name' I had earlier but I've fixed them all now and the email if working, just need to sort out the code to do with the validation of the form before allowing it to submit. i.e. no blank required fields.

Thanks

mindee
01-16-2010, 02:12 PM
it would help to know, which line of your code line 73 is. nevertheless I suspect a missing concatenation operator.

Thank you Dormilich, not sure what a concatenation operator is but TomWS' response helped a lot. Sorry, I couldn't bring in the line numbers to post.

Preety new to coding HTML, php or whatever, just have a small project helping my wife develop her website on the cheap side. Thank you for your help

Dormilich
01-16-2010, 03:05 PM
concatenation operator (http://www.php.net/manual/en/language.operators.string.php)

either that or the semicolon (chance has been 50%)...

mindee
01-16-2010, 06:55 PM
concatenation operator (http://www.php.net/manual/en/language.operators.string.php)

either that or the semicolon (chance has been 50%)...

Thanks I understand now.

I understand a bit of MS Access query writing and can just about write IF statements there. Do you know the search strings I should use in Google (or a particularly good tutorial site online) and what aspects of php syntax I should be looking for when wanting to validate whether fields are populated before moving on to the next stage please.

I was using the following code I copied from somewhere but I think it is incomplete but what do I know?



if(empty($fullname) || empty($birth_date1) || empty($birth_date2) || empty($birth_date3) || empty($address) || empty($country) || empty($town) || empty($postcode) || empty($email) || empty($phone_day) || empty($accept1) || empty($accept2) || empty($accept3))
{
echo "<H2>Use Back - fill in all fields (*) </H2>\n";
die ("<H2>Use back! ! </H2>");
}

I'm I on the right track?

Thank you

tomws
01-16-2010, 10:11 PM
"php form validation" might be a good one.

Dormilich
01-17-2010, 10:02 AM
when validating user input, have a look at PHP filter functions (http://php.net/filter).

tomws
01-17-2010, 06:42 PM
when validating user input, have a look at PHP filter functions (http://php.net/filter).

That's good stuff. I haven't seen it before. Looks like it could be quite useful.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum