Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Problems with PHP script

  1. #1
    Join Date
    Feb 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problems with PHP script

    Gday Guys

    Are am having some problems with a PHP form. It seems i keep getting a PHP error which i cannot fix. I am new to web page development and this is my first site.

    If anyone can help, the website is Toucan Club
    Go to Crew and fillin the form and this is the error i get....

    Parse error: parse error in C:\Inetpub\vhosts\toucanclub.com.au\httpdocs\Crew.php on line 59

    And here is the PHP code...

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
    <?php



    ?>

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta name="generator" content="Adobe GoLive" />
    <title>Untitled Page</title>
    <link href="css/basic.css" type="text/css" rel="stylesheet" media="all" />
    </head>

    <body bgcolor="#ffffff">
    <p><?php
    // Website Contact Form Generator
    // http://www.tele-pro.co.uk/scripts/contact_form/
    // This script is free to use as long as you
    // retain the credit link

    // get posted data into local variables
    $EmailFrom = Trim(stripslashes($_POST['Email']));
    $EmailTo = "info@helivisuals.com.au";
    $Subject = "Crew Application";
    $Crew = Trim(stripslashes($_POST['Crew']));
    $FirstName = Trim(stripslashes($_POST['FirstName']));
    $LastName = Trim(stripslashes($_POST['LastName']));
    $ContactPhone = Trim(stripslashes($_POST['ContactPhone']));
    $BirthDay = Trim(stripslashes($_POST['BirthDay']));
    $BirthMonth = Trim(stripslashes($_POST['BirthMonth']));
    $BirthYear = Trim(stripslashes($_POST['BirthYear']));
    $Address = Trim(stripslashes($_POST['Address']));
    $State = Trim(stripslashes($_POST['State']));
    $PostCode = Trim(stripslashes($_POST['PostCode']));
    $Country = Trim(stripslashes($_POST['Country']));
    $Otherdetails = Trim(stripslashes($_POST['Other Details']));


    // validation
    $validationOK=true;
    if (Trim($Crew)=="") $validationOK=false;
    if (Trim($Email)=="") $validationOK=false;
    if (Trim($ContactPhone)=="") $validationOK=false;
    if (Trim($FirstName)=="") $validationOK=false;
    if (Trim($LastName)=="") $validationOK=false;
    if (Trim($Address)=="") $validationOK=false;
    if (Trim($State)=="") $validationOK=false;
    if (Trim($PostCode)=="") $validationOK=false;
    if (Trim($Country)=="") $validationOK=false;
    if (!$validationOK) {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html">";
    exit;
    }

    // prepare email body text
    ($Body) .= "Crew: "; // <--------this is line 59!
    $Body .= $Crew;
    $Body .= "\n";
    $Body .= "FirstName: ";
    $Body .= $FirstName;
    $Body .= "\n";
    $Body .= "LastName: ";
    $Body .= $LastName;
    $Body .= "\n";
    $Body .= "ContactPhone: ";
    $Body .= $ContactPhone;
    $Body .= "\n";
    $Body .= "Address: ";
    $Body .= $Address;
    $Body .= "\n";
    $Body .= "Birthday: ";
    $Body .= $Birthday, $BirthMonth, $BirthYear;
    $Body .= "\n";
    $Body .= "State: ";
    $Body .= $State;
    $Body .= "\n";
    $Body .= "PostCode: ";
    $Body .= $PostCode;
    $Body .= "\n";
    $Body .= "Country: ";
    $Body .= $Country;
    $Body .= "\n";
    $Body .= "Other Details: ";
    $Body .= $Otherdetails;
    $Body .= "\n";

    // send email
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

    // redirect to success page
    if ($success){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html">";
    }
    else{
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html">";
    }
    ?></p>
    </body>

    </html>

  2. #2
    Join Date
    Feb 2007
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
    <?php
    
    
    
    ?>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta name="generator" content="Adobe GoLive" />
    <title>Untitled Page</title>
    <link href="css/basic.css" type="text/css" rel="stylesheet" media="all" />
    </head>
    
    <body bgcolor="#ffffff">
    <p><?php
    // Website Contact Form Generator
    // http://www.tele-pro.co.uk/scripts/contact_form/
    // This script is free to use as long as you
    // retain the credit link
    
    // get posted data into local variables
    $EmailFrom = Trim(stripslashes($_POST['Email']));
    $EmailTo = "info@helivisuals.com.au";
    $Subject = "Crew Application";
    $Crew = Trim(stripslashes($_POST['Crew']));
    $FirstName = Trim(stripslashes($_POST['FirstName']));
    $LastName = Trim(stripslashes($_POST['LastName']));
    $ContactPhone = Trim(stripslashes($_POST['ContactPhone']));
    $BirthDay = Trim(stripslashes($_POST['BirthDay']));
    $BirthMonth = Trim(stripslashes($_POST['BirthMonth']));
    $BirthYear = Trim(stripslashes($_POST['BirthYear']));
    $Address = Trim(stripslashes($_POST['Address']));
    $State = Trim(stripslashes($_POST['State']));
    $PostCode = Trim(stripslashes($_POST['PostCode']));
    $Country = Trim(stripslashes($_POST['Country']));
    $Otherdetails = Trim(stripslashes($_POST['Other Details']));
    
    
    // validation
    $validationOK=true;
    if (Trim($Crew)=="") $validationOK=false;
    if (Trim($Email)=="") $validationOK=false;
    if (Trim($ContactPhone)=="") $validationOK=false;
    if (Trim($FirstName)=="") $validationOK=false;
    if (Trim($LastName)=="") $validationOK=false;
    if (Trim($Address)=="") $validationOK=false;
    if (Trim($State)=="") $validationOK=false;
    if (Trim($PostCode)=="") $validationOK=false;
    if (Trim($Country)=="") $validationOK=false;
    if (!$validationOK) {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
    exit();
    }
    // prepare email body text
    $Body .= "Crew: "; // <--------this is line 59!
    $Body .= $Crew;
    $Body .= "\n";
    $Body .= "FirstName: ";
    $Body .= $FirstName;
    $Body .= "\n";
    $Body .= "LastName: ";
    $Body .= $LastName;
    $Body .= "\n";
    $Body .= "ContactPhone: ";
    $Body .= $ContactPhone;
    $Body .= "\n";
    $Body .= "Address: ";
    $Body .= $Address;
    $Body .= "\n";
    $Body .= "Birthday: ";
    $Body .= $Birthday . $BirthMonth . $BirthYear;
    $Body .= "\n";
    $Body .= "State: ";
    $Body .= $State;
    $Body .= "\n";
    $Body .= "PostCode: ";
    $Body .= $PostCode;
    $Body .= "\n";
    $Body .= "Country: ";
    $Body .= $Country;
    $Body .= "\n";
    $Body .= "Other Details: ";
    $Body .= $Otherdetails;
    $Body .= "\n";
    
    // send email
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
    
    // redirect to success page
    if ($success){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html\">";
    }
    else{
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
    }
    ?></p>
    </body>
    
    </html>
    "Rock and roll ain't noise pollution." - AC/DC

    http://www.blake-foster.com

  3. #3
    Join Date
    Feb 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    sorry Blake, did i miss something?

  4. #4
    Join Date
    Feb 2007
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I fixed your code. The lines I changed are in bold. There were just some minor syntax errors, nothing conceptual.
    "Rock and roll ain't noise pollution." - AC/DC

    http://www.blake-foster.com

  5. #5
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Blake simply escaped the quotes using a backslash. Compare the two codes and you should see it. Although (to Blake), it would be wise to show what changes you made to a code snippet by changing the color. This helps both the OP and anyone else trying to find a solution.

    Hope this helps.

    EDIT: Sorry Blake, cross posted.

  6. #6
    Join Date
    Feb 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    sweet! thanks heaps! you are a life saver

    apologies aswell, it was hard to see the bolder lines you edited.

  7. #7
    Join Date
    Feb 2007
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by kaliedoscope View Post
    sweet! thanks heaps! you are a life saver

    apologies aswell, it was hard to see the bolder lines you edited.
    No prob. Maybe I'll use color instead of bold next time, as thetestingsite suggested.
    "Rock and roll ain't noise pollution." - AC/DC

    http://www.blake-foster.com

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
    Whut the heck? That be the darndest lukin' frameset ah ever did see! Also, you decided to drop support for IE?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Feb 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey View Post
    Whut the heck? That be the darndest lukin' frameset ah ever did see! Also, you decided to drop support for IE?
    umm, sorry mate, like I said, im a website n00b. This 'may' be the problem why the email won't send?

    Blake has done an excellent job of getting the form to submit and go to the ok.html page, but for some reason, i do not recieve an email of the data in the form....

    i have deleted the exit from this section

    if (!$validationOK) {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html\">";
    exit();
    }

    as i thought it was exiting the php before the form data was sent, but that made no difference.

    Thanks again

  10. #10
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    you want this:

    if (!$validationOK) {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html\">";
    die();
    }

    Stops the script right away.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

Bookmarks

Posting Permissions

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