Form Problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rjmxracer1
Forum Newbie
Posts: 6
Joined: Tue Dec 30, 2003 9:09 am

Form Problems

Post 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{
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Umm show us your code... and comment where line 111 is
rjmxracer1
Forum Newbie
Posts: 6
Joined: Tue Dec 30, 2003 9:09 am

more code

Post 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>"

}
?>
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post 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.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post 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....
rjmxracer1
Forum Newbie
Posts: 6
Joined: Tue Dec 30, 2003 9:09 am

Code

Post 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
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post 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>";
}
?>
Post Reply