tim_ver Posted April 9, 2007 Share Posted April 9, 2007 I keep getting this error when I submit my online form: Parse error: syntax error, unexpected T_STRING This is the line it is complaining about: if ($autotype = 1){mail(email to, Email, Thank you for your request. We will be in touch in 24 hours.)}; What am I missing? Thanks Quote Link to comment Share on other sites More sharing options...
jitesh Posted April 9, 2007 Share Posted April 9, 2007 if ($autotype == 1) Quote Link to comment Share on other sites More sharing options...
tim_ver Posted April 9, 2007 Author Share Posted April 9, 2007 Nope same error still. This is what I have now and also the line above it $autotype; if ($autotype == 1){mail(email to, Email, Thank you for your request. We will be in touch in 24 hours.)}; Quote Link to comment Share on other sites More sharing options...
neel_basu Posted April 9, 2007 Share Posted April 9, 2007 if($autotype == 1) { $header = "From: you@domain.com \r\n"; mail("receipent@domain.com", "Subject", "Thank you for your request We will be in touch in 24 hours", $header); } Next Time Please use Tree Style PHP Coding Quote Link to comment Share on other sites More sharing options...
tim_ver Posted April 9, 2007 Author Share Posted April 9, 2007 Ok, but with your changes it does not do hat I want it to. I want to email the response to the email they enter in the email box on the form. I have 4 forms and each are numbered 1-4 so each get a unique response back. Thanks Quote Link to comment Share on other sites More sharing options...
neel_basu Posted April 9, 2007 Share Posted April 9, 2007 I am not going to make you all. You have to configure that code block by yourself according to your needs. I've Just Told that Replace if ($autotype = 1){mail(email to, Email, Thank you for your request. We will be in touch in 24 hours.)}; With The Above Code I Posted Quote Link to comment Share on other sites More sharing options...
tim_ver Posted April 9, 2007 Author Share Posted April 9, 2007 Ok, I am new to this way of auto response. The issue is the all forms goto the same email account so I need to have a different response for each form defined. I figured this was the easiest but it is not turing out to be it now, better way to do this? I have have four forms and on each for I have this code: $autotype autotype = 1 Then in the send.php the code you gave above plus the line above it I gave. I want it to email the response detailed in the line to the email they give in the text box on the form. So what I am thinking is that the line you have receipent@domain.com need to be replaced with a value like Email and then Email has to be defined in the Send.php, right? Thanks Quote Link to comment Share on other sites More sharing options...
tim_ver Posted April 9, 2007 Author Share Posted April 9, 2007 Anyone help me on this, just need a little direction. Thanks Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 10, 2007 Share Posted April 10, 2007 Anyone help me on this, just need a little direction. Thanks And http://www.phpfreaks.com/forums/index.php/topic,134291.msg565336.html#msg565336 isn't all the direction you already need? If not, better explain why. Quote Link to comment Share on other sites More sharing options...
btherl Posted April 10, 2007 Share Posted April 10, 2007 I think he is asking about use of a variable for the email address. You can do if($autotype == 1) { $header = "From: you@domain.com \r\n"; $email = "recipient@domain.com"; mail($email, "Subject", "Thank you for your request We will be in touch in 24 hours", $header); } Similarly, you can replace the subject and/or the message with a variable. If you are still having trouble, please post your full code for us to look at (for just 1 of the forms). There may be a problem with getting data from the form into the variables as well. Quote Link to comment Share on other sites More sharing options...
tim_ver Posted April 10, 2007 Author Share Posted April 10, 2007 Ok will do. The forms work fine and I am getting the great just no auto responders are being sent back to the email the users put in the form. Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 10, 2007 Share Posted April 10, 2007 It's time to post your code for the form handling script. Quote Link to comment Share on other sites More sharing options...
tim_ver Posted April 11, 2007 Author Share Posted April 11, 2007 Ok here it is for form1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Form1</title> <style type="text/css"> <!-- body,td,th { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; } body { background-image: url(); background-repeat: repeat-y; background-position:center; background-color:#ffffff; margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } --> </style> </style> <script type="text/javascript" language="javascript" charset="utf-8"> // <![CDATA[ function Check() { error = ''; if(document.frm.Email.value=='') { error += 'Email is required\n'; } if(document.frm.First_Name.value=='') { error += 'First name is required\n'; } if(document.frm.Last_Name.value=='') { error += 'Last name is required\n'; } if(document.frm.Phone_Number.value=='') { error += 'Phone number is required\n'; } if(error!=''){ window.alert(error); return false; } return true; } // ]]> $autotype autotype = 1 </script> </head> <body> <table width="754" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td> </td> </tr> <tr> <td background="images/bg.jpg" align="center"> </td> </tr> <tr> <td> </td> </tr--> <tr> <td height="1955"> <h1 align="center">Online form1</h1> <form name="frm" method="post" action="send.php?ID=<?=$_GET['ID'];?>" onsubmit="javascript: return Check();"> <table width="100%" cellpadding="12"> <tr> <td>Please fill out this form.</td> </tr> <tr><td>Right now I am:</td></tr> <tr><td> <input type="radio" name="Right_now_I_am" value="Ready to hire"/> Ready<br/> <input type="radio" name="Right_now_I_am" value="Evaluating "/> Evaluating<br/> <input type="radio" name="Right_now_I_am" value="Looking for information"/> Looking for information</td></tr> <tr><td>I would like to complete this project by:</td></tr> <tr><td> <? $months[1] = "January"; $months[2] = "February"; $months[3] = "March"; $months[4] = "April"; $months[5] = "May"; $months[6] = "June"; $months[7] = "July"; $months[8] = "August"; $months[9] = "September"; $months[10] = "October"; $months[11] = "November"; $months[12] = "December"; ?> <select name="Project_completion_month"> <option value="">Month</option> <? foreach($months as $month){ ?> <option value="<?=$month;?>"><?=$month;?></option> <? } ?> </select> <select name="Project_completion_year"><option value="">Year</option><? for($now = date('Y'), $i=($now+50); $i>=($now-50); $i--){?><option value="<?=$i;?>"><?=$i;?></option><?}?></select> </td></tr> <tr><td align="justify">What is your total budget for your project?</td></tr> <tr><td> <select name="Total_Budget"> <option value="Less than $ 300" selected>Less than $ 300</option> <option value="$300 to $ 1000">$300 to $ 1000</option> </select> </td></tr> <tr><td align="justify">What type of project?</td></tr> <tr><td> <input type="checkbox" name="Type_of_project[1]" value="New"/> Project1<br/> <input type="checkbox" name="Type_of_project[2]" value="Existing"/> Project2<br/> <input type="checkbox" name="Type_of_project[3]" value="Major "/> Project3<br/> <input type="checkbox" name="Type_of_project[4]" value="Add To"/> Project4</td> </tr> <tr><td align="justify">Please describe the type of project you are looking to have complete:</td></tr> <tr><td> <textarea name="Describe_type_of_project" style="width:100%; height: 50px;"></textarea> </td></tr> <tr> <td align="justify">Do you have any questionsl.</td> </tr> <tr><td> <select name="survey"> <option value="--">--</option> <option value="Yes">Yes</option> <option value="No">No</option> </select> </td></tr> <tr><td> <textarea name="Additional_Details" style="width:100%; height: 50px;"></textarea> </td></tr> <tr> <td><b>Street Address:</b></td> </tr> <tr><td><input type="text" name="Address" size="60"/></td></tr> <tr><td>City:</td></tr> <tr><td><input type="text" name="City" size="30"/></td></tr> <tr><td>State:</td></tr> <tr><td><input type="text" name="State" size="2"/></td></tr> <tr><td>Zip Code:</td></tr> <tr><td><input type="text" name="Zip" size="5"/></td></tr> <tr><td><b>Your Contact Information:</b></td></tr> <tr><td><font color="red">*</font>Email:</td></tr> <tr><td><input name="Email" type="text" size="30"/></td></tr> <tr><td><font color="red">*</font>First Name:</td></tr> <tr><td><input type="text" name="First_Name" size="40"/></td></tr> <tr><td><font color="red">*</font>Last Name:</td></tr> <tr><td><input type="text" name="Last_Name" size="40"/></td></tr> <tr><td><font color="red">*</font>Phone Number you can be reached at 8-5. M-F:</td></tr> <tr><td><input type="text" name="Phone_Number" size="20"/></td></tr> <tr><td>Additional Services</td></tr> <tr> <td align="justify">Please select other services that you need :</td> </tr> <tr><td> <input type="checkbox" name="Additional_services[1]" value="one"/>one<br/> <input type="checkbox" name="Additional_services[2]" value="two"/>two<br/> <input type="checkbox" name="Additional_services[3]" value="three"/> three</td> </tr> <tr><td>How did you find out about this website:</td></tr> <tr><td> <select name="How_did_you_find_us"> <option value="Online">Online</option> <option value="Newspaper">Newspaper</option> <option value="Magazine">Magazine</option> <option value="Word of mouth">Word of mouth</option> <option value="Radio">Radio</option> <option value="TV">TV</option> </select> </td></tr> <tr><td align="center"><input type="submit"/></td></tr> <tr> <td colspan="2"><font color="red">* = Fields are required</font></td> </tr> </table> </form> <p> </p></td> </tr> </table> <center> </center> </body> </html> Quote Link to comment Share on other sites More sharing options...
neel_basu Posted April 11, 2007 Share Posted April 11, 2007 There Is no Syntax Error on this Script Quote Link to comment Share on other sites More sharing options...
tim_ver Posted April 11, 2007 Author Share Posted April 11, 2007 So why is it not working? What am I missing? I am not getting the auto response back. Thanks Quote Link to comment Share on other sites More sharing options...
neel_basu Posted April 11, 2007 Share Posted April 11, 2007 Check your Junk Mail Folder first Quote Link to comment Share on other sites More sharing options...
tim_ver Posted April 11, 2007 Author Share Posted April 11, 2007 There is no junk mail folder for the email I enter. I did try also a yahoo and checked all folders but nothing. Arghhh Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 11, 2007 Share Posted April 11, 2007 Nice that we see the html form, but ... It's time to post your code for the form handling script. ... that's send.php Quote Link to comment Share on other sites More sharing options...
tim_ver Posted April 11, 2007 Author Share Posted April 11, 2007 Ahh ok here is the send.php code: <?php if($_GET['ID']!=''){ session_start(); require('include/kaip.php'); check_install(); c_mysql_connect(); $result = c_mysql_query('SELECT * FROM listings WHERE listing_approved = 1 AND listing_id = %P LIMIT 1', array($_GET['ID'])); if(mysql_num_rows($result) != 0) { $row = mysql_fetch_assoc($result); } }else{ $row['listing_contact'] = "info@mydomain.com"; $row['listing_title'] = "Contact"; } include("class.phpmailer.php"); $mail = new PHPMailer(); $mail->From = $_POST['Contact_Name']; $autotype; if($autotype == 1) { $header = "From: mydomain.com \r\n"; $email = "info@mydomain.com"; mail($email, "Subject", "Thank you for your request We will be in touch in 24 hours", $header); } if($_GET['ID']!=''){ $mail->FromName = "{$_POST['First_Name']} {$_POST['Last_Name']}"; $mail->Subject = "Request1"; }else{ $mail->FromName = "{$_POST['Contact_Name']}"; $mail->Subject = "Contact form"; } $text = "\n"; $html = "<table>"; foreach($_POST as $v=>$l){ if(is_array($l)) $l=implode(', ', $l); $text .= "{$v}: {$l}\n\n"; $html .= "<tr><td>{$v}:</td><td> {$l}</td></tr>"; } $html .= "</table>"; $mail->Body = $html; $mail->AltBody = $text; $mail->AddAddress($row['listing_contact'], $row['listing_title']); if($row['listing_cccontact']!='') $mail->AddAddress($row['listing_cccontact'], $row['listing_title']); //$mail->AddAttachment($_FILES['attach']['tmp_name'], $_FILES['attach']['name']); if(!$mail->Send()) echo "There has been a mail error sending to Contact<br>"; // Clear all addresses and attachments for next loop $mail->ClearAddresses(); $mail->ClearAttachments(); ?> <script language="Javascript"> window.alert("Thank you for your request.\n We will contact you soon."); window.location = "index.php"; </script> (edited to put in the tags) Quote Link to comment Share on other sites More sharing options...
tim_ver Posted April 12, 2007 Author Share Posted April 12, 2007 Ok so what am I missing? Thanks Quote Link to comment Share on other sites More sharing options...
neel_basu Posted April 12, 2007 Share Posted April 12, 2007 I dont no about phpmailer Class I know about the group_mail Class http://zigmoyd.sourceforge.net/man/mail.php#group_mailHere you can under what is actually happening. and it works fine for me. Quote Link to comment Share on other sites More sharing options...
tim_ver Posted April 12, 2007 Author Share Posted April 12, 2007 Arghh, ok. This looks to be different then what I am after though. Anyone know how to fix the issue with the code I am using? Or am I out of luck? Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.