hanwei Posted March 22, 2008 Share Posted March 22, 2008 Hi guys, i have some problem here. i tried to create a form script whereby it will straight away send a mail to my email address once the submit is clicked, without going through database. But it doesn't work. im a newbie in scripting, so hope u guys can help me. thanks in advance <? $link = mysql_connect("127.0.0.1", "mysql") or die("Could not connect: " . mysql_error()); mysql_select_db("ttmodule", $link) or die("Unable to select database: . mysql_error()"); ?> <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns="http://www.w3.org/TR/REC-html40"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Trouble Ticket Submission</title> </head> <body style="background:transparent url(images/body_repeat.jpg) repeat scroll 0%" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0"> <table border="0" cellpadding="0" cellspacing="0" width="1003" height="740"> <tr> <td></td><td><font size="6" color="white"> E-Gold Order Form</font></td> </tr> <tr> </tr> <tr> <td colspan="2" height="76" align="left" dir="ltr" width="1183"> <b><font color="#FFFFFF" size="5"> </font></b></td> </tr> <td msopnltype="NavBody" width="214" align="left" valign="top" dir="ltr"><p dir="ltr"><b> <font color="#FFFFFF"> <font size="2" face="Arial Narrow"> <img border="0" src="bullet.JPG" width="17" height="14"></font> <a href="main.htm" style="text-decoration: none"> <font face="Arial Narrow" size="2" color="#F0FFFF">Home</font></a></b><p dir="ltr"><b> <font size="2" face="Arial Narrow"> <img border="0" src="bullet.JPG" width="17" height="14"></font> <font color="#F0FFFF" size="2" face="Arial Narrow"> <a href="about-us.htm" style="text-decoration: none"> <font color="#F0FFFF">About Us</font></a></font></b><p dir="ltr"><b> <font size="2" face="Arial Narrow"> <img border="0" src="bullet.JPG" width="17" height="14"></font> <font color="#F0FFFF" size="2" face="Arial Narrow"> <a href="fee.htm" style="text-decoration: none"> <font color="#F0FFFF">Exchange Rate</font></a></font></b><p dir="ltr"><b> <font size="2" face="Arial Narrow"> <img border="0" src="bullet.JPG" width="17" height="14"></font> </b> <a href="sellgold.htm" style="text-decoration: none"><b> <font face="Arial Narrow" size="2" color="#F0FFFF">Buy </font></b></a><b> <font color="#F0FFFF" size="2" face="Arial Narrow"> <a href="sellgold.htm" style="text-decoration: none"> <font color="#F0FFFF">E-Gold</font></a></font></b><p dir="ltr"><b> <font size="2" face="Arial Narrow"> <img border="0" src="bullet.JPG" width="17" height="14"></font> <font color="#F0FFFF" size="2" face="Arial Narrow"> <a href="faq.htm" style="text-decoration: none"> <font color="#F0FFFF">Frequently Asked Question</font></a></font></b><p dir="ltr"><b> <font size="2" face="Arial Narrow"> <img border="0" src="bullet.JPG" width="17" height="14"></font> <font color="#F0FFFF" size="2" face="Arial Narrow"> <a href="contact.htm" style="text-decoration: none"> <font color="#F0FFFF">Contact Us</font></a></font></b><td valign="top" height="484" width="789"> <font color="#FFFFFF"><font face="Arial">Please fill in all your details to ensure valid submission.</font><br> </font></p> <font color="#FF0000"><? printf($_REQUEST['submiterror']); ?></font> <p dir="ltr"><font color="#FFFFFF"><br></font></p> <form method="POST" action="mailto:[email protected]"> <table border="0" align="" cellpadding="0" cellspacing="0" id="form_border" dir="ltr" height="404"> <tr> <th width="25%" align=right dir="ltr" height="20"> <font face="Arial" color="#FFFFFF">Title: </font></th> <td dir="ltr" height="20"> <font color="#FFFFFF" face="Arial"> <input type=radio value="Mr" name="clientTitle" checked >Mr <input type=radio value="Mrs" name="clientTitle" >Mrs <input type=radio value="Ms" name="clientTitle" >Ms <input type=radio value="Dr" name="clientTitle" >Dr </font> </td> </tr> <tr> <th align=right width="394" dir="ltr" height="23"> <font face="Arial" color="#FFFFFF">Full Name: </font></th> <td dir="ltr" height="23" ><font color="#FFFFFF"> <!--webbot bot="Validation" s-data-type="String" b-allow-letters="TRUE" i-maximum-length="40" --><input maxlength=40 name="cusName" class="textfield" value="" size="20"> </font> </td> </tr> <tr> <td align="right" dir="ltr" height="23"><font face="Arial" color="#FFFFFF"><b>Email Address: </b></font></td> <td align="right" dir="ltr" height="23"> <p align="left" dir="ltr"> <font color="#FFFFFF"> <input maxlength=90 name="cusEmail" class="textfield" value="" size="20"></font></td> </tr> <tr> <td align="right" dir="ltr" height="23"><font face="Arial" color="#FFFFFF"><b>Amount of eGold: </b></font></td> <td align="right" dir="ltr" height="23"> <p align="left" dir="ltr"> <font color="#FFFFFF"> <input maxlength=90 name="cusGold" class="textfield" value="" size="20"></font></td> </tr> <tr> <td align="right" dir="ltr" height="23"><font color="#FFFFFF"><b><font face="Arial">E-G</font></b><font face="Arial"><b>old Account Number: </b></font></font></td> <td align="right" dir="ltr" height="23"> <p align="left" dir="ltr"> <font color="#FFFFFF"> <!--webbot bot="Validation" s-data-type="Number" s-number-separators=".," b-value-required="TRUE" i-minimum-length="7" i-maximum-length="7" s-validation-constraint="Greater than or equal to" s-validation-value="0000000" s-validation-constraint="Less than or equal to" s-validation-value="9999999" --><input maxlength=7 name="cusEAcc" class="textfield" value="" size="20"></font></td> </tr> <tr> <th align=right width="394" dir="ltr" height="23"> <font face="Arial" color="#FFFFFF">PayPal Email Address: </font></th> <td dir="ltr" height="23" ><font color="#FFFFFF"> <!--webbot bot="Validation" s-data-type="String" b-allow-letters="TRUE" i-maximum-length="40" --><input maxlength=40 name="cusPPadd" class="textfield" value="" size="20"> </font> </td> </tr> <tr> <td align="right" dir="ltr" height="23"><font face="Arial" color="#FFFFFF"><b>MSN/Yahoo Address: </b></font></td> <td align="right" dir="ltr" height="23"> <p align="left" dir="ltr"> <font color="#FFFFFF"> <!--webbot bot="Validation" s-data-type="String" b-allow-letters="TRUE" i-maximum-length="90" --><input maxlength=90 name="cusAdd" class="textfield" value="" size="20"></font></td> </tr> <tr> <th align=right width="394" dir="ltr" height="28"> </th> <td dir="ltr" height="28" > <font color="#FFFFFF"> <input type="submit" value="Submit"> </font> <p> </p> <p> </td> </tr> </table> </form> <font face="Verdana" size="2"> <span style="COLOR: #FFFFFF; FONT-FAMILY: MS Shell Dlg">© Copyright www.globalgoldmart.com, 2008. All rights reserved. </span> </font> </td> </tr> <tr> </tr> </table> </body> </html> <? mysql_close($link); ?> Link to comment https://forums.phpfreaks.com/topic/97333-need-help-regarding-sending-form-to-email/ Share on other sites More sharing options...
cunoodle2 Posted March 22, 2008 Share Posted March 22, 2008 Do NOT use forms like that with the mailto link. It doesn't work reliably for all visitors to your site. Whether or not a visitor can use this method depends on the mail client installed on their computer. And unfortunately, there's no way to test if that's the case for each of your visitors. This can lead to the worst kind of situation where someone takes to time to give you feedback, then finds that they can't send the information to you! You should instead use the form to post to a php page which then sends out an e-mail. Here is a sample from a page I recently did. The form page.. <form name="index2" action="../index2.php" method="post"> <div align="center"> <table cellpadding="2" width="100%" border="0"> <tbody> <tr> <td valign="middle" align="center" width="50%">Full Name</td> <td valign="middle" align="left" width="50%"><input name="Name" size="20"></td> </tr> <tr> <td valign="middle" align="center" width="50%">E-Mail Address</td> <td valign="middle" align="left" width="50%"><input name="EMail" size="20"></td> </tr> <tr> <td valign="middle" align="center" width="50%">Re-Enter Your Email For Verification</td> <td valign="middle" align="left" width="50%"><input name="EMail1" size="20"></td> </tr> <tr> <td valign="middle" align="center" width="50%">Domain Name</td> <td valign="middle" align="left" width="50%"><input name="Domain" size="20"></td> </tr> <tr> <td valign="middle" align="center" width="50%">Ticket Subject</td> <td valign="middle" align="left" width="50%"><input name="Subject" size="20"></td> </tr> The mailing out page... if ($_POST['Name'] != "") { $Name = isSet($_POST['Name']) ? $_POST['Name'] : NULL; $EMail = isSet($_POST['EMail']) ? $_POST['EMail'] : NULL; $EMail1 = isSet($_POST['EMail1']) ? $_POST['EMail1'] : NULL; $Domain = isSet($_POST['Domain']) ? $_POST['Domain'] : NULL; $Subject = isSet($_POST['Subject']) ? $_POST['Subject'] : NULL; } $content = "Hello there here is some stuff like this ".$Domain."\n";; $content .= "And yes how about this stuff here ".$Subject."\n"; mail("[email protected]","Email subject", $content, "Return-Path: $EMail\nReply-to: $EMail\nFrom: $EMail"); That should get you off to a very good start. Don't just use some basic form. Use php to build out a nice e-mail. Send one to yourself and while you are at it send a thank you e-mail to your client. Its just the professional way to handle things. Link to comment https://forums.phpfreaks.com/topic/97333-need-help-regarding-sending-form-to-email/#findComment-498063 Share on other sites More sharing options...
ryeman98 Posted March 22, 2008 Share Posted March 22, 2008 <form method="POST" action="mailto:[email protected]"> I hope you realize that the action is useless. You have to send the data to a section of php code and send it using the mail() function. Try to find a good tutorial on google, it's really simple. Edit: Use cunoodle2's code, that will work the way you want it to. If that doesn't work, your host may not support the mail() function. Link to comment https://forums.phpfreaks.com/topic/97333-need-help-regarding-sending-form-to-email/#findComment-498065 Share on other sites More sharing options...
hanwei Posted March 28, 2008 Author Share Posted March 28, 2008 hi cunoodle2, i have tried using ur both of your script to do a simple sendmail, but there's no result. I mean it will show a error page once i press the submit button. So i would like to know, is it possible to send mail without uploading the script to the net, but straight away direct myform to my sendmail.php script(which is located in my harddrive) and send out an email. thanks in advance.. Link to comment https://forums.phpfreaks.com/topic/97333-need-help-regarding-sending-form-to-email/#findComment-503123 Share on other sites More sharing options...
hanwei Posted March 28, 2008 Author Share Posted March 28, 2008 i have tried to post my script in geocities for testing purpose.. when i click on the submit button, a warning box will popout. It says 'This form is being submitted Link to comment https://forums.phpfreaks.com/topic/97333-need-help-regarding-sending-form-to-email/#findComment-503210 Share on other sites More sharing options...
discomatt Posted March 28, 2008 Share Posted March 28, 2008 cunoodle2's script is open to mail header injection http://www.securephpwiki.com/index.php/Email_Injection It's always smart to check for newlines in the user's input, and die or log when it's detected. Link to comment https://forums.phpfreaks.com/topic/97333-need-help-regarding-sending-form-to-email/#findComment-503221 Share on other sites More sharing options...
hanwei Posted March 28, 2008 Author Share Posted March 28, 2008 i have tried uploading my 2 script on geocities for testing purposes this is the problem i encounter: when i click on the submit button, it will be directed into a blank page. I think its because i didn't direct the sendmail.php to a confirmation script.(correct me if im wrong). But it did not send to my email. can anyone help me to solve this problem. is it because of my script?? thanks in advance.. this is my sendmail.php <? if ($_POST['Name'] != "") { $Name = isSet($_POST['Name']) ? $_POST['Name'] : NULL; $Email = isSet($_POST['Email]) ? $_POST['Email'] : NULL; $Egold = isSet($_POST['Egold']) ? $_POST['egold'] : NULL; $acc = isSet($_POST['acc']) ? $_POST['acc'] : NULL; $PPadd = isSet($_POST['ppadd']) ? $_POST['ppadd'] : NULL; $msn = isSet($_POST['msn']) ? $_POST['msn'] : NULL; } mail("[email protected]","testing", $Egold, "testing"); ?> this is my form script <? $link = mysql_connect("127.0.0.1", "mysql") or die("Could not connect: " . mysql_error()); mysql_select_db("ttmodule", $link) or die("Unable to select database: . mysql_error()"); ?> <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns="http://www.w3.org/TR/REC-html40"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>GlobalGoldMart</title> </head> <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0" background="images/body_repeat.jpg"> <table border="0" cellpadding="0" cellspacing="0" width="1183" height="327"> <tr> <td valign="bottom" bgcolor="#003366" colspan="2" height="54" align="left" width="1183"> </td> </tr> <tr> <td colspan="2" height="76" align="left" dir="ltr" width="1183"> <b><font color="#FFFFFF" size="5"> </font></b></td> </tr> <tr> <td msopnltype="NavBody" width="223" align="left" valign="top" dir="ltr" height="36"> <td valign="top" height="41" width="960" dir="ltr"> <font size="5" color="#FFFFFF" face="Arial"><b>xxxb></div> </font> <font size="5" face="Arial"> </font> </font> </td> </tr> <tr> <td msopnltype="NavBody" width="223" align="left" valign="top" dir="ltr" height="36"> <td valign="top" height="36" width="960" dir="ltr"> </td> </tr> <td msopnltype="NavBody" width="223" align="left" valign="top" dir="ltr" height="533"> <p dir="ltr"><b> <font color="#FFFFFF"> <font size="2" face="Arial Narrow"> <img border="0" src="bullet.JPG" width="17" height="14"></font> </font> <a href="main.htm" style="text-decoration: none"> <font face="Arial Narrow" size="2" color="#FFFFFF">xxx</font></a></b><p dir="ltr"> <b><font color="#FFFFFF"><font face="Arial Narrow" size="2"> <img border="0" src="bullet.JPG" width="17" height="14"></font> </font> <font color="#003470" size="2" face="Arial Narrow"> <a href="about-us.htm" style="text-decoration: none"> <font color="#FFFFFF">xxx</font></a></font></b><p dir="ltr"><b> <font color="#FFFFFF"> <font size="2" face="Arial Narrow"> <img border="0" src="bullet.JPG" width="17" height="14"></font> </font> <font color="#003470" size="2" face="Arial Narrow"> <a href="fee.htm" style="text-decoration: none"> <font color="#FFFFFF">xxx</font></a></font></b><p dir="ltr"> <font color="#FFFFFF"><b> <font size="2" face="Arial Narrow"> <img border="0" src="bullet.JPG" width="17" height="14"></font> </b> </font> <a href="sellgold.htm" style="text-decoration: none"><b> <font face="Arial Narrow" size="2" color="#FFFFFF">Buy </font></b></a><b> <font color="#003470" size="2" face="Arial Narrow"> <a href="sellgold.htm" style="text-decoration: none"> <font color="#FFFFFF">xxx</font></a></font></b><p dir="ltr"><b> <font color="#FFFFFF"> <font size="2" face="Arial Narrow"> <img border="0" src="bullet.JPG" width="17" height="14"></font> </font> <font color="#003470" size="2" face="Arial Narrow"> <a href="faq.htm" style="text-decoration: none"> <font color="#FFFFFF">xxx</font></a></font></b><p dir="ltr"><b> <font color="#FFFFFF"> <font size="2" face="Arial Narrow"> <img border="0" src="bullet.JPG" width="17" height="14"></font> </font> <font color="#003470" size="2" face="Arial Narrow"> <a href="contact.htm" style="text-decoration: none"> <font color="#FFFFFF">xxx</font></a></font></b><p dir="ltr"> </p> <p dir="ltr"> </p> <p dir="ltr"> </p> <p dir="ltr"> </p> <p dir="ltr"> </p> <p dir="ltr"> </p> <table style="BORDER-COLLAPSE: collapse" borderColor="#111111" height="56" cellSpacing="0" cellPadding="0" width="100%" border="1"> <tr> <td width="13%" height="31"> </td> <td width="87%" height="31"><font color="#ffffff"> <img src="images/egold.gif" border="0" width="88" height="31"></font></td> </tr> <tr> <td width="100%" colSpan="2" height="24"><font color="#ffffff"> Free Account</font></td> </tr> </table> <p dir="ltr"> </p> <p dir="ltr"><b> <td valign="top" height="533" width="960" dir="ltr"> <p dir="ltr"><font color="#FFFFFF"><font face="Arial">Please fill in all your details to ensure valid submission.</font><br> </font></p> <form name="testing" action="sendmail.php" method="post"> <table border="0" align="" cellpadding="0" cellspacing="0" id="form_border" dir="ltr" height="404"> <tr> <th width="25%" align=right dir="ltr" height="20"> </tr> <tr> <th align=right width="394" dir="ltr" height="23"> <font face="Arial" color="#FFFFFF">Full Name: </font></th> <td valign="middle" align="left" width="50%"><input name="Name" size="20"></td></font></td> </tr> <tr> <td align="right" dir="ltr" height="23"> <font face="Arial" color="#FFFFFF"><b>Email Address:</b> </font></td> <td valign="middle" align="left" width="50%"><input name="Email" size="20"></td></font></td> </tr> <tr> <td align="right" dir="ltr" height="23"><font face="Arial" color="#FFFFFF"><b>Amount of eGold:</b> </font></td> <td valign="middle" align="left" width="50%"><input name="egold" size="20"></td></font></td> </tr> <tr> <td align="right" dir="ltr" height="23"><font face="Arial" color="#FFFFFF"><b>E-Gold Account Number:</b> </font></td> <td valign="middle" align="left" width="50%"><input name="acc" size="20"></td></font></td> </tr> <tr> <td align="right" dir="ltr" height="23"><font face="Arial" color="#FFFFFF"><b>PayPal Email Address:</b> </font></td> <td valign="middle" align="left" width="50%"><input name="ppadd" size="20"></td></font></td> </tr> <tr> <td align="right" dir="ltr" height="23"><font face="Arial" color="#FFFFFF"><b>MSN/Yahoo Address:</b> </font></td> <td valign="middle" align="left" width="50%"><input name="msn" size="20"></td></font></td> </tr> <tr> <th align=right width="394" dir="ltr" height="28"> </th> <td dir="ltr" height="28" > <font color="#FFFFFF"> <input type="submit" value="Submit"> </font> <p> </p> <p> </td> </tr> </table> </form> <p> <font face="Verdana" size="2"> <span style="COLOR: #FFFFFF; FONT-FAMILY: MS Shell Dlg">© Copyright xxx, 2008. All rights reserved. </span> </font> </td> </tr> <tr> <td valign="top" height="126" align="left" colspan="2" width="1183"> </td> </tr> </table> </body> </html> <? mysql_close($link); ?> Link to comment https://forums.phpfreaks.com/topic/97333-need-help-regarding-sending-form-to-email/#findComment-503236 Share on other sites More sharing options...
hanwei Posted March 29, 2008 Author Share Posted March 29, 2008 up~~~ :-\ Link to comment https://forums.phpfreaks.com/topic/97333-need-help-regarding-sending-form-to-email/#findComment-503731 Share on other sites More sharing options...
hanwei Posted March 30, 2008 Author Share Posted March 30, 2008 up~~~?? Link to comment https://forums.phpfreaks.com/topic/97333-need-help-regarding-sending-form-to-email/#findComment-504446 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.