YoungDuPage Posted July 2, 2008 Share Posted July 2, 2008 The server says: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/kazafoxc/public_html/mailform.php on line 124 <?phpif (isset($_POST['email']))//if "email" is filled out, send email { //send email $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $Parameters = $_POST['name']; mail("my@example.com", "Subject: $subject", $message, "From: $email" ); echo "Thank you for using our mail form"; }else//if "email" is not filled out, display the form { echo "<form method='post' action='mailform.php'> Email: <input name='email' type='text' /><br /> Subject: <input name='subject' type='text' /><br /> Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea><br /> <input type='submit' value="Send" class="button" /> </form>"; }?> line 124 is right before the last line. i dont know what the problem is? Link to comment Share on other sites More sharing options...
Ingolme Posted July 2, 2008 Share Posted July 2, 2008 Change the double quotes on this line for single quotes, or escape them:<input type='submit' value="Send" class="button" /> Link to comment Share on other sites More sharing options...
justsomeguy Posted July 2, 2008 Share Posted July 2, 2008 <input type='submit' value="Send" class="button" />You either need to escape those double quotes or change them to single quotes.Jinx! Link to comment Share on other sites More sharing options...
YoungDuPage Posted July 2, 2008 Author Share Posted July 2, 2008 oh, yea. haha.I cant seem to display more information in the email form.i can only getemail:subject:message: Link to comment Share on other sites More sharing options...
Synook Posted July 2, 2008 Share Posted July 2, 2008 Is that what you see in the email?? Link to comment Share on other sites More sharing options...
Jack McKalling Posted July 2, 2008 Share Posted July 2, 2008 I changed the code you posted, this should work: <?phpif (isset($_POST['email']))//if "email" is filled out, send email { //send email $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $Parameters = $_POST['name']; mail("my@example.com", "Subject: $subject", $message, "From: $email" ); echo "Thank you for using our mail form"; }else//if "email" is not filled out, display the form { echo "<form method='post' action='mailform.php'> Email: <input name='email' type='text' /><br /> Subject: <input name='subject' type='text' /><br /> Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea><br /> <input type='submit' value='Send' class='button' /> </form>"; }?> However, you could also rewrite it like this: <?phpif (isset($_POST['email']) == true && isset($_POST['subject']) == true && isset($_POST['message']) == true) //if "email" is filled out, send email{ //send email $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $Parameters = $_POST['name']; mail("my@example.com", "Subject: $subject", $message, "From: $email" ); echo "Thank you for using our mail form";} else //if "email" is not filled out, display the form{ echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>", "\r\n Email: <input name='email' type='text' /><br />", "\r\n Subject: <input name='subject' type='text' /><br />", "\r\n Message:<br />", "\r\n <textarea name='message' rows='15' cols='40'></textarea><br />", "\r\n <input type='submit' value='Send' class='button' />", "\r\n</form>";}?> You could also instead of just checking if the fields are set, validate them against your own rules.Second, this form will always post its data to itself, renaming this file will not cause the submit to become invalid this way :)Third, this way of echoing makes it a little more readable, and you now have controll over how you write your strings. They can be indented, makes your complete code more organised. Link to comment Share on other sites More sharing options...
YoungDuPage Posted July 3, 2008 Author Share Posted July 3, 2008 im not very familiar with php. i just need another parameter to request the users name. <?phpif (isset($_POST['email']))//if "email" is filled out, send email { //send email $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $Parameters = $_POST['name']; mail("team@kazafox.com", "Subject: $subject", $message, "From: $email" ); echo "Thank you for using our mail form"; }else//if "email" is not filled out, display the form { echo "<form method='post' action='mailform.php'> <p><label>Email:</label><br> <input name='email' type='text' /><br /> <p><label>Name:</label><br> <input name='name' type='text' /><br /> <p><label>Subject:</label><br> <input name='subject' type='text' /><br /> <p><label>Message:</label><br> <textarea name='message' rows='15' cols='40'> </textarea><br /> <input type='submit' value='Send' class='button' /> </form>"; }?> Link to comment Share on other sites More sharing options...
justsomeguy Posted July 3, 2008 Share Posted July 3, 2008 These lines show the label and the input: <p><label>Email:</label><br> <input name='email' type='text' /><br />You can copy and paste those to put whatever you want in the form, wherever you want it. The corresponding line in the PHP script:$email = $_POST['email'];Uses the same value in the "name" attribute in the input tag to get the value that was submitted. You can put their name in the subject, or the from email address, or the message, or wherever you want it to appear in the email. Link to comment Share on other sites More sharing options...
YoungDuPage Posted July 4, 2008 Author Share Posted July 4, 2008 I tried to have the users name display in the message, but it wont show up Link to comment Share on other sites More sharing options...
YoungDuPage Posted July 4, 2008 Author Share Posted July 4, 2008 I can only get the users name to replace their email. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 4, 2008 Share Posted July 4, 2008 The . operator joins 2 strings. There are a couple examples here:http://www.php.net/manual/en/language.operators.string.phpYou can add the name to the $message variable, or join the name and email for the subject, or wherever you want to put it. Link to comment Share on other sites More sharing options...
YoungDuPage Posted July 4, 2008 Author Share Posted July 4, 2008 can you make multiple data collecting files? or can you only have one file called mailform.php? and how do i make one of the variables a selection. such as: <select name="business"> <option value="">::::Business Cards::::</option> <option value="">::::Email Marketing::::</option> <option value="" selected="selected">::::Marketing Networks::::</option> Link to comment Share on other sites More sharing options...
YoungDuPage Posted July 4, 2008 Author Share Posted July 4, 2008 can you make multiple data collecting files? or can you only have one file called mailform.php? and how do i make one of the variables a selection. such as:$userschoice <select name="business"><option value="">::::Business Cards::::</option><option value="">::::Email Marketing::::</option><option value="" selected="selected">::::Marketing Networks::::</option></select> Link to comment Share on other sites More sharing options...
Synook Posted July 4, 2008 Share Posted July 4, 2008 can you make multiple data collecting files? or can you only have one file called mailform.php?You can't submit a form to multiple pages (at least without using an asynchronous method such as AJAX). Your processing page doesn't, however, have to be called mailform.php.and how do i make one of the variables a selection. such as: $userschoice <select name="userschoice"><option value="1">::::Business Cards::::</option><option value="2">::::Email Marketing::::</option><option value="3" selected="selected">::::Marketing Networks::::</option></select> Will end up in $_POST['userschoice'] (the selected option's value will be assigned, so giving them all a value of "" isn't really helpful). Link to comment Share on other sites More sharing options...
YoungDuPage Posted July 4, 2008 Author Share Posted July 4, 2008 what is "Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING"indicating? Link to comment Share on other sites More sharing options...
Jack McKalling Posted July 4, 2008 Share Posted July 4, 2008 You can see a list of all the parser tokens of php.net here:http://www.php.net/manual/en/tokens.phpIt is the occurance of string in a place where it is not expected, I believe Link to comment Share on other sites More sharing options...
jeffman Posted July 4, 2008 Share Posted July 4, 2008 Yah. The "T" stands for token and is so generic to parsing errors that it means everything and nothing. The key word in there is "string." How do strings go wrong? Usually in the quotation marks. Ingolme and JSG identified the correct error in posts 2-3 above. The reason it's an error is that when your string reached this point:value="the quote was interpreted as a closing quote, and the string is ended. So now the parser is trying to figure out the meaning of the stuff that comes after, and it hits some problems: 1. there is no ";" at the end of the previous statement, and 2. the statement-like structureSend" class="button" /></form>";makes no sense in PHP. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.