Log in

View Full Version : Problems with PHP script



kaliedoscope
02-26-2007, 01:02 PM
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 (http://www.toucanclub.com.au)
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>

Blake
02-26-2007, 01:43 PM
<!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>

kaliedoscope
02-28-2007, 05:04 AM
sorry Blake, did i miss something?

Blake
02-28-2007, 05:15 AM
I fixed your code. The lines I changed are in bold. There were just some minor syntax errors, nothing conceptual.

thetestingsite
02-28-2007, 05:19 AM
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.

kaliedoscope
02-28-2007, 05:33 AM
sweet! thanks heaps! you are a life saver :)

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

Blake
02-28-2007, 05:35 AM
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.

Twey
02-28-2007, 05:15 PM
<!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?

kaliedoscope
03-01-2007, 12:40 PM
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

boxxertrumps
03-01-2007, 01:47 PM
you want this:

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

Stops the script right away.

Twey
03-01-2007, 04:36 PM
exit() and die() are synonyms.
umm, sorry mate, like I said, im a website n00b. This 'may' be the problem why the email won't send?No, but it's still bad practice. Use HTML 4.01 Strict.

kaliedoscope
03-02-2007, 12:30 AM
but why would i want to exit the script after validation is complete?
doesnt that mean that the email wont compile and send after this point?

even if i remove the exit() after validationOK, the email wont send.

After entering details in this (http://www.toucanclub.com.au/index-4.html) webpage, it looks like it all working but i dont think anything is happening in the background.

Cheers

mburt
03-02-2007, 12:41 AM
die and ext also end all php scripts as well, so if you had any other php scripts on that page, they would all get removed after the point of execution.

kaliedoscope
03-02-2007, 12:54 AM
die and ext also end all php scripts as well, so if you had any other php scripts on that page, they would all get removed after the point of execution.

arh okay, thanks mburt.

Still can't figure out why i wont recieve an email tho... the address is correct and ive tried a hotmail address aswell but with no success.

maybe i should create a simple script that just sends a blank email from the page to see if that works, and if that works, its something to do with the email compilation...

thetestingsite
03-03-2007, 01:25 AM
Still can't figure out why i wont recieve an email tho... the address is correct and ive tried a hotmail address aswell but with no success.

Do you get any error messages? The most likely cause would be the server that it is hosted on, or the server that your hosts uses to send mail. If after trying to make a simple page to send an email doesn't work, try a different server.

Hope this helps

kaliedoscope
03-12-2007, 02:40 PM
thankyou for everyones help.
I now managed to successfully lodge forms by removing the die() or exit() code halfway through the php. It was quitting the form too early before it could get the data from the fields and email them!

Cheers again!!