Page 1 of 1

Form Problems

Posted: Sun Feb 08, 2004 10:39 am
by rjmxracer1
I am trying to set up a form on one of my web sites, i am very new to PHP programing. I set it up with a method of post, and it is being submitted to an e-mail. However when you try to go to the page, which is questions.php you get a response "Parse error: parse error, unexpected T_ELSE in /home/content/r/s/c/rscrwc/html/questions.php on line 111" Does this have to do with the PHP that i wrote or do i need to set up a database and have the database work with the information to submit it to me?
Any help would be greatly appreciated. Thank you :?
Line 111 of the page is the tag } else{

Posted: Sun Feb 08, 2004 10:42 am
by John Cartwright
Umm show us your code... and comment where line 111 is

more code

Posted: Sun Feb 08, 2004 2:11 pm
by rjmxracer1
Line 111 is the " } else { " tag
<?
} else{
mail('rjmxracer1@yahoo.com', 'Form submission', $_POST['personal_name'] $_POST['company_name'] $_POST['contact_phone']
$_POST['contact_e-mail'] $_POST['current_web'] $_POST['web_url_already'] $_POST['purpose']
$_POST['updated']
echo "<SCRIPT language=JavaScript>window.location.replace(\"index.htm\")</SCRIPT>"

}
?>

Posted: Sun Feb 08, 2004 3:44 pm
by DuFF
You probably didn't end some other statement before starting the "else" or you have an "else" where it shouldn't be. Please show us the entire code, just that section doesn't help.

Posted: Sun Feb 08, 2004 3:52 pm
by Illusionist
jsut in your above code i dont see any semi-colons (;) go back through your code and add a ';' to the end of each line....

Code

Posted: Sun Feb 08, 2004 4:40 pm
by rjmxracer1
That is the entire PHP code.... everything else is the form on the page .... the error has to be in the code there, what do you mean a ; at teh end of each line does that mean at the end of the actual line or each peice of code like after the Post

Posted: Sun Feb 08, 2004 4:49 pm
by DuFF
Well, if thats the entire PHP code, you can't just end something with a bracket that you haven't even started!

Code: Select all

<?php
} /* <---- */ else{  
?>
You need an if statement to see if the form has been submitted. Without seeing the HTML I can't really tell you how to do this. BTW, this is what he means by putting semicolons at the end of each line (VERY IMPORTANT IN PROGRAMMING, EVERY SINGLE LANGUAGE [that i know of] USES THIS!)

Code: Select all

<?php
if ($something == "something")
{
$content = "Name: " . $_POST['personal_name'] . "\n";  //all of this will make the e-mail much prettier   
$content .= "Company Name: " . $_POST['company_name'] . "\n";
$content .= "Phone #: " . $_POST['contact_phone'] . "\n";
$content .= "E-mail: " . $_POST['contact_e-mail'] . "\n";
$content .= "Current Web: " . $_POST['current_web'] . "\n";
$content .= "Web URL already: " . $_POST['web_url_already'] . "\n";
$content .= "Purpose: " . $_POST['purpose'] . "\n";
$content .= "Updated: " . $_POST['updated'] . "\n";

mail('rjmxracer1@yahoo.com', 'Form submission', $content);
echo "<SCRIPT language=JavaScript>window.location.replace("index.htm")</SCRIPT>";
}
?>