coolcolin09 Posted April 28, 2008 Share Posted April 28, 2008 Hey guys. I'm a real newbie to PHP. I'm trying to create a simple script to just send the email and give them a summary of what they wrote. However, I'm getting the following error, and I don't know what to do. Help would be much appreciated! Parse error: syntax error, unexpected T_ECHO in C:\wamp\www\Glenwick Yard Services\email.php on line 48 (Line 48 is labeled and bolded) <?php // Create shorthand for the form data $firstname = $_REQUEST['firstname']; $lastname = $_REQUEST['lastname']; $email = $_REQUEST['email']; $comments = $_REQUEST['text']; // Check form Submission if (isset($_POST["submitted"])) { // Minimal Form Submission if (!empty($_POST['firstname']) && !empty($_POST['lastname']) && !empty($_POST['email']) && !empty($_POST['text']) ) { // Create the Body (format of Email) $body = "First Name: {$_POST['firstname']}\n\nLast Name: {$_POST['lastname']}\n\nEmail: {$_POST['email']}\n\nComments: {$_POST['text']}"; // Make it no longer than 70 characters long (WordWrap) $body = wordwrap($body, 70); // Send the Email mail('[email protected]', 'Contact Form Submission', $body, "From: {$_POST['email']}") // Print a Message LINE 48 echo '<p><em>Thank you for contacting us, <b>$firstname</b>! We will respond to you within 12 hours at <b>$email</b></em></p>'; // Clear $_POST so that the form's not sticky $_POST = array(); } else { echo '<p style="font-weight: bold; color: #C00">Oops! You forgot to fill out some information! We would like to remind you that no information will be shared with anyone!</p>'; } } ?> I know you guys are very advanced at this stuff, and I feel a little dumb, but I just can't figure it out! Thanks... Link to comment https://forums.phpfreaks.com/topic/103199-email-problem/ Share on other sites More sharing options...
DarkWater Posted April 28, 2008 Share Posted April 28, 2008 Which error would be "the following error"? =P Link to comment https://forums.phpfreaks.com/topic/103199-email-problem/#findComment-528605 Share on other sites More sharing options...
coolcolin09 Posted April 28, 2008 Author Share Posted April 28, 2008 lol sorry let me number it really quick Link to comment https://forums.phpfreaks.com/topic/103199-email-problem/#findComment-528608 Share on other sites More sharing options...
dptr1988 Posted April 28, 2008 Share Posted April 28, 2008 On line 39, you forgot a semicolon at the end of the call to the mail() function. Also, do you ever indent your code, or was that just a posting mistake: Corrected code: <?php // Create shorthand for the form data $firstname = $_REQUEST['firstname']; $lastname = $_REQUEST['lastname']; $email = $_REQUEST['email']; $comments = $_REQUEST['text']; // Check form Submission if (isset($_POST["submitted"])) { // Minimal Form Submission if (!empty($_POST['firstname']) && !empty($_POST['lastname']) && !empty($_POST['email']) && !empty($_POST['text']) ) { // Create the Body (format of Email) $body = "First Name: {$_POST['firstname']}\n\nLast Name: {$_POST['lastname']}\n\nEmail: {$_POST['email']}\n\nComments: {$_POST['text']}"; // Make it no longer than 70 characters long (WordWrap) $body = wordwrap($body, 70); // Send the Email mail('************@gmail.com', 'Contact Form Submission', $body, "From: {$_POST['email']}"); // Print a Message echo '<p><em>Thank you for contacting us, <b>$firstname</b>! We will respond to you within 12 hours at <b>$email</b></em></p>'; // Clear $_POST so that the form's not sticky $_POST = array(); } else { echo '<p style="font-weight: bold; color: #C00">Oops! You forgot to fill out some information! We would like to remind you that no information will be shared with anyone!</p>'; } } ?> Link to comment https://forums.phpfreaks.com/topic/103199-email-problem/#findComment-528609 Share on other sites More sharing options...
coolcolin09 Posted April 28, 2008 Author Share Posted April 28, 2008 Thanks, I'll fix that as well. No I don't indent that much yet, still getting the hang of it. Thanks for that! Link to comment https://forums.phpfreaks.com/topic/103199-email-problem/#findComment-528613 Share on other sites More sharing options...
dptr1988 Posted April 28, 2008 Share Posted April 28, 2008 Note: If your email address, 'glenwic********@gmail.com' is valid, you might want to remove it from these posts, to avoid spam. Link to comment https://forums.phpfreaks.com/topic/103199-email-problem/#findComment-528616 Share on other sites More sharing options...
coolcolin09 Posted April 28, 2008 Author Share Posted April 28, 2008 Well now the error is not there anymore. However, even when I do fill out all the information, it comes back with the message that says "Oops, you forgot to fill out some information!....", which obviously is not supposed to come up if I fill everything out! Thanks! Link to comment https://forums.phpfreaks.com/topic/103199-email-problem/#findComment-528618 Share on other sites More sharing options...
coolcolin09 Posted April 28, 2008 Author Share Posted April 28, 2008 Note: If your email address, 'glenwic********@gmail.com' is valid, you might want to remove it from these posts, to avoid spam. it's not, it's fake Link to comment https://forums.phpfreaks.com/topic/103199-email-problem/#findComment-528620 Share on other sites More sharing options...
coolcolin09 Posted April 28, 2008 Author Share Posted April 28, 2008 Well now the error is not there anymore. However, even when I do fill out all the information, it comes back with the message that says "Oops, you forgot to fill out some information!....", which obviously is not supposed to come up if I fill everything out! Thanks! Link to comment https://forums.phpfreaks.com/topic/103199-email-problem/#findComment-528633 Share on other sites More sharing options...
dptr1988 Posted April 28, 2008 Share Posted April 28, 2008 try var_dump($_POST) to see the contents of your $_POST vars. Also check the names on your HTML forms. Why do you have this code: <?php $firstname = $_REQUEST['firstname']; $lastname = $_REQUEST['lastname']; $email = $_REQUEST['email']; $comments = $_REQUEST['text']; ?> and the go on to access those variables by the $_POST array? Link to comment https://forums.phpfreaks.com/topic/103199-email-problem/#findComment-528640 Share on other sites More sharing options...
coolcolin09 Posted April 28, 2008 Author Share Posted April 28, 2008 not sure what you mean by var_dump($_POST). I'll remove the $_REQUEST variables that you refferred to last post. Thanks. Link to comment https://forums.phpfreaks.com/topic/103199-email-problem/#findComment-528650 Share on other sites More sharing options...
dptr1988 Posted April 28, 2008 Share Posted April 28, 2008 if you add var_dump($_POST); near the begining of your file, it will print out the contents of the $_POST array, which contains the data that was submitted from the form. It will help you debug this script. Link to comment https://forums.phpfreaks.com/topic/103199-email-problem/#findComment-528666 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.