chubba Posted January 11, 2008 Share Posted January 11, 2008 Hi Guys I am new to this, i have having trouble getting an email form to work. I need to work out the code that will go in the contact.php. The form code on the contact us page is: <form name="form" action="contact.php" method="get"> <div class="box_left column"> <div class="tt"><input type="text" value="Your Name:" /></div> <div class="tt"><input type="text" value="Your Fax:" /></div> <div class="tt"><input type="text" value="Your Phone:" /></div> <input type="text" value="Your E-mail:" /> </div> <div class="box_right column"> <textarea cols="3" rows="3">Your Message:</textarea> <strong style="margin:0 21px 0 102px;"><a href="javascript:form.reset();"><strong>clear</strong></a> <a href="javascript:form.submit();"><strong>send</strong></a> </div> <div class="clear"></div> </form> I just need the information to get sent to outlook, With The sender email as in From: Persons name in subject: and Fax and Phone numbers and message to make up the message. Can anyone please advise? Link to comment https://forums.phpfreaks.com/topic/85502-can-somebody-please-help-email-form/ Share on other sites More sharing options...
priti Posted January 11, 2008 Share Posted January 11, 2008 what you have written in your contact.php ?? please refer link http://in2.php.net/function.mail which explain mail() function. Regards Link to comment https://forums.phpfreaks.com/topic/85502-can-somebody-please-help-email-form/#findComment-436358 Share on other sites More sharing options...
monkeytooth Posted January 13, 2008 Share Posted January 13, 2008 Well short of laying it out for you.. I notice one thing you deffinately need is name variables for your input fields... you have <input type="text" value="Your Name:" /> you should have <input type="text" value="Your Name:" name="name" /> as far as the contact.php there after if you want to do it yourself I would advise you to goto php.net and look into $_POST $_Get functions as well as the mail() function.. otherwise I might be able to help you if you like.. Link to comment https://forums.phpfreaks.com/topic/85502-can-somebody-please-help-email-form/#findComment-437891 Share on other sites More sharing options...
bajangerry Posted January 15, 2008 Share Posted January 15, 2008 Naming your variable is essential, then it is as simple as this: <? //send the email $mail_sent = @mail( $to, $subject, $message, $headers ); //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" echo $mail_sent ? "Mail sent" : "Mail failed"; ?> Link to comment https://forums.phpfreaks.com/topic/85502-can-somebody-please-help-email-form/#findComment-439915 Share on other sites More sharing options...
monkeytooth Posted January 15, 2008 Share Posted January 15, 2008 its that simple yes with the mail function but I would personally beef it up a notch with distinct headers an what not. Just in attempts to avoid it from being kicked back by some systems, and out of bulk folders on others, a few other random reasons.. but thats just me, its not necessary 100% to have all this but its nice.. something like: (which this is a sample that would work for sending HTML based emails but you could strip out the HTML elements from the message part and just do plain ol text if you like).. $to = '[email protected]' . ', '; // note the comma $to .= '[email protected]'; // subject $subject = '[MT Contact] ' . $_POST["T3"]; // message $message = ' <html> <head> <title>[MT Contact] $_POST["T3"]</title> </head> <body> <table> <tr> <th>Data Type</th><th>Input Data</th> </tr> <tr> <td>Name:</td><td>' . $_POST["T1"] . '</td> </tr> <tr> <td>Company:</td><td>' . $_POST["T2"] . '</td> </tr> <tr> <td>Email:</td><td>' . $_POST["T3"] . '</td> </tr> </table> </body> </html> '; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: Contact <[email protected]>' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); Link to comment https://forums.phpfreaks.com/topic/85502-can-somebody-please-help-email-form/#findComment-440231 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.