jamesclues Posted February 24, 2009 Share Posted February 24, 2009 Hi I am very new to PHP i used to use asp but I thought I would try PHP My Problem is changing a send mail script FIELD NAMES BELOW. firstname surname address town postocde telephone emailaddress enquiry ------------------------------------ Email Example Sent to My Self me@domain.com Subject New Enquiry from Web Site. firstname surname address town postocde telephone emailaddress enquiry ------------------------------------- Email Example Sent to User to Confirm Dear firstname Subject New Enqury from domain.com Thank you for you email we will be in touch soon. after send redirected to a THANKS.PHP I dunno how to do this Quote Link to comment Share on other sites More sharing options...
gevans Posted February 24, 2009 Share Posted February 24, 2009 Do you have a script that you're already using? If you just want a starting point have a look at the manual: mail If you want help with some code you're already using post it Quote Link to comment Share on other sites More sharing options...
jamesclues Posted February 24, 2009 Author Share Posted February 24, 2009 Well the only code I have is in ASP. So I need to convert this into PHP I have never used PHP in my life till today and have no idea where to start I have search forums and web sites but nothing what i need <% dim firstname dim surname dim address dim town dim postocde dim telephone dim emailaddress dim enquiry firstname=request.form("firstname") surname=request.form("surname") address=request.form("address") town=request.form("town") postocde=request.form("postocde") telephone=request.form("telephone") emailaddress=request.form("emailaddress") enquiry=request.form("enquiry") dim msg1 msg1="<p>Contact Request from Web Site</p>" msg1=msg1 & "<b>First Name:</b> " & firstname & "<br>" msg1=msg1 & "<b>Last Name:</b> " & surname & "<br>" msg1=msg1 & "<b>Last Name:</b> " & address & "<br>" msg1=msg1 & "<b>Last Name:</b> " & town & "<br>" msg1=msg1 & "<b>Last Name:</b> " & postocde & "<br>" msg1=msg1 & "<b>Last Name:</b> " & telephone & "<br>" msg1=msg1 & "<b>Last Name:</b> " & emailaddress & "<br>" msg1=msg1 & "<b>Last Name:</b> " & enquiry & "<br>" Set JMail = Server.CreateObject("JMail.SMTPMail") JMail.ServerAddress = "smtp.domain.co.uk:25" JMail.Sender = emailaddress JMail.Subject = "Subject Enquiry" JMail.AddRecipient "info@domain.com" JMail.ContentType = "text/html" JMail.Body = msg1 JMail.Priority = 0 JMail.Execute %> <% dim msg2 msg2="<b>Dear " & firstname & "</b>" msg2=msg2 & "<p>Thank you for contacting us.</p>" msg2=msg2 & "<p>We will contact you in the next 24 hours</p>" Set JMail = Server.CreateObject("JMail.SMTPMail") JMail.ServerAddress = "smtp.Domain.co.uk:25" JMail.Sender = "info@Domain.com" JMail.Subject = "Doman Enquiry" JMail.AddRecipient emailaddress JMail.ContentType = "text/html" JMail.Body = msg2 JMail.Priority = 0 JMail.Execute %> <html><head><meta http-equiv="refresh" content="1;url=http://www.domain.com/thankyou.asp"><title>Domain</title> </head><br><br><br> <br><center><font color=#000000 face=arial size=3> <b>SENDING EMAIL TO DOMAIN.COM</font><br><br> <font color=#000000 face=arial size=4> <br>http://www.Domains.com</b></font></center> </body></html> Quote Link to comment Share on other sites More sharing options...
gevans Posted February 24, 2009 Share Posted February 24, 2009 Well if you're familiar with asp you should be pretty adaptable. CLICKY That's the page of the manual you need; have a read through that and it will explain everything you need to send the mail. If you're getting details from a web form that require assigning to a var I'd recommend looking at some basic tutorials so you get the jist of variables and superglobals (the basics) of php. Quote Link to comment Share on other sites More sharing options...
jamesclues Posted February 25, 2009 Author Share Posted February 25, 2009 I have a Form which is on contact.html and posts the data to send.php Contact Form Fields FIELD NAMES BELOW. name address town postocde telephone email enquiry <? if($_POST["send"]) { //collect post variables $name = $_POST["name"]; $address = $_POST["address"]; $town = $_POST["town"]; $postocde = $_POST["postocde"]; $telephone = $_POST["telephone"]; $email = $_POST["email"]; $enquiry = $_POST["enquiry"]; //build email body $body .= "Name: $name \n"; $body .= "Address: $address \n"; $body .= "Town: $town \n"; $body .= "Postcode: $postcode \n"; $body .= "Telephone: $telephone \n"; $body .= "Email: $email \n"; $body .= "Enquiry: $enquiry \n"; //create email headers $headers = 'From: '.$email. "\r\n" . 'Reply-To: ' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); //send $send = mail("info@domain.co.uk","Online Enquiry"); ?> <? if($_POST["send"]) { //collect post variables $name = $_POST["name"]; $email = $_POST["email"]; //build email body $body .= "Name: $name \n"; $body .= "Thank you for your Enquiry \n"; //create email headers $headers = 'From: 'info@domain.co.uk "\r\n" . 'Reply-To: ' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); //send $send = mail("$email","Online Enquiry"); ?> Still having issue got some code off a web site but still does not work Quote Link to comment Share on other sites More sharing options...
gevans Posted February 25, 2009 Share Posted February 25, 2009 $send = mail("info@domain.co.uk","Online Enquiry"); You're not adding the emssage or your headers; <?php $send = mail("info@domain.co.uk","Online Enquiry",$body,$headers); Quote Link to comment Share on other sites More sharing options...
jamesclues Posted February 25, 2009 Author Share Posted February 25, 2009 Parse error: syntax error, unexpected T_STRING in send.php on line 47 Line 47 = $headers = 'From: 'test@domain.com' "\r\n" . Full Code of Area where problem Happening. //create email headers $headers = 'From: 'test@domain.com' "\r\n" . 'Reply-To: ' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); Quote Link to comment Share on other sites More sharing options...
DarkSuperHero Posted February 25, 2009 Share Posted February 25, 2009 $headers = 'From: 'test@domain.com' "\r\n". //rest of headers code continues...thats why theres dot.. should probably read $headers = "From: 'test@domain.com' \r\n". //rest of headers code continues...thats why theres dot.. of possibly $headers = 'From: 'test@domain.com'."\r\n". //rest of headers code continues...thats why theres dot.. The apostrophe, and/or quotation marks are were not matching up... Quote Link to comment Share on other sites More sharing options...
jamesclues Posted February 25, 2009 Author Share Posted February 25, 2009 Still not working now i get Parse error: syntax error, unexpected $end in send.php on line 54 Line 54 is ?> <? if($_POST["send"]) { //collect post variables $name = $_POST["name"]; $address = $_POST["address"]; $town = $_POST["town"]; $postocde = $_POST["postocde"]; $telephone = $_POST["telephone"]; $email = $_POST["email"]; $enquiry = $_POST["enquiry"]; //build email body $body .= "Name: $name \n"; $body .= "Address: $address \n"; $body .= "Town: $town \n"; $body .= "Postcode: $postcode \n"; $body .= "Telephone: $telephone \n"; $body .= "Email: $email \n"; $body .= "Enquiry: $enquiry \n"; //create email headers $headers = 'From: '.$email. "\r\n" . 'Reply-To: ' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); //send $send = mail("test@domain.com","Online Enquiry",$body,$headers); ?> <? if($_POST["send"]) { //collect post variables $name = $_POST["name"]; $email = $_POST["email"]; //build email body $body .= "Name: $name \n"; $body .= "Thank you for your Enquiry \n"; //create email headers $headers = "From: 'test@domain.com' \r\n". 'Reply-To: ' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); //send $send = mail("$email","Online Enquiry",$body,$headers); ?> Quote Link to comment Share on other sites More sharing options...
jamesclues Posted February 26, 2009 Author Share Posted February 26, 2009 Can anyone help please.... Still not working now i get Parse error: syntax error, unexpected $end in send.php on line 54 Line 54 is ?> ??? 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.