Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10

Thread: php email help

  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    php email help

    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
    Attached Files Attached Files
    Last edited by mindee; 01-16-2010 at 01:30 AM.

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,446
    Thanks
    13
    Thanked 361 Times in 357 Posts
    it would help to know, which line of your code line 73 is. nevertheless I suspect a missing concatenation operator.

  • #3
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Please wrap your code in php tags. It's much easier to read. It also would have helped to spot the problem:
    PHP Code:
    $subject "New FM Global Team Sign Up" 
    You're missing a semicolon there.

    Other problems:
    PHP Code:
    $_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
    PHP Code:
    $my_variable
    There's nothing happening. The obvious way to assign is like this:
    PHP Code:
    $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.
    Are you a Help Vampire?

  • Users who have thanked tomws for this post:

    mindee (01-16-2010)

  • #4
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tomws View Post
    Please wrap your code in php tags. It's much easier to read. It also would have helped to spot the problem:
    PHP Code:
    $subject "New FM Global Team Sign Up" 
    You're missing a semicolon there.

    Other problems:
    PHP Code:
    $_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
    PHP Code:
    $my_variable
    There's nothing happening. The obvious way to assign is like this:
    PHP Code:
    $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

  • #5
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    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

  • #6
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,446
    Thanks
    13
    Thanked 361 Times in 357 Posts
    concatenation operator

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

  • Users who have thanked Dormilich for this post:

    mindee (01-16-2010)

  • #7
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    concatenation operator

    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?


    PHP Code:
    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
    Last edited by mindee; 01-16-2010 at 08:27 PM. Reason: tagging properly

  • #8
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    "php form validation" might be a good one.
    Are you a Help Vampire?

  • #9
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,446
    Thanks
    13
    Thanked 361 Times in 357 Posts
    when validating user input, have a look at PHP filter functions.

  • Users who have thanked Dormilich for this post:

    tomws (01-17-2010)

  • #10
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Quote Originally Posted by Dormilich View Post
    when validating user input, have a look at PHP filter functions.
    That's good stuff. I haven't seen it before. Looks like it could be quite useful.
    Are you a Help Vampire?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •