|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
html form printed to php page
Hi all,
Maybe you can help me resolve a problem I am having with a form. A friend of mine has asked me to design him a coupon voucher for his website, in which I did. The coupon voucher is a html form. The person fills out their name, email and phone. Once they hit submit, the results of the form then gets printed to a php page in which the person filling the form prints out to submit it to the company. All is working fine, except my friend is also wanting the form results to be emailed to him, along with the submitted form results. I am just learning php and I sure would appreciate some input on how to do this. Form people fillout. This is the html page code (partial): <HTML><title>Save 10% off on auto repair NOW!</title> <BODY bottomMargin=0 bgColor=#ffffff leftMargin=0 topMargin=0 rightMargin=0 background="images/cert-bg.gif" marginwidth="0" marginheight="0"> <form method="POST" action="certificate2.php"> <TABLE align="center" cellSpacing=0 cellPadding=0 border=0 bgcolor="#FFFFFF" background="images/cert-bg.gif" width=500 height="100"> <TBODY> <TR> <TD vAlign=top width=2 rowspan="4"><IMG height=25 src="../images/spacers/blank.gif" width=2></TD> <TD vAlign=top width=513 height="30"><P align=center style="margin-top: 0; margin-bottom: 0"> <FONT style="font-size: 20pt; text-decoration: underline"><font face="Arial, Helvetica, sans-serif" size="+3"><strong>RMS Auto Care</strong></font></FONT><BR> <font face="Arial, Helvetica, sans-serif" size="3">7000 Synott - Houston, TX 77072<br> 281-498-3535 - 281-498-3271 fax </font><BR> <DIV align="center"> <TABLE border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="70" id="Certificate1"> <TBODY> <TR> <TD height="12"> </TD> <TD height="12" valign="top"><img src="../images/spacers/blank.gif" width="1" height="15"></TD> </TR> <TR> <TD width="1" height="12"> <IMG border="0" src="../images/spacers/spacer_1X35wh.gif" width="1" height="35"></TD> <TD width="530" height="12" valign="top"> <p><FONT face="Arial" style="font-size: 9pt"><font face="Arial, Helvetica, sans-serif" size="2">We'd like to thank you for visiting our website! When it comes the time for you to have body work, body paint or mechanical repairs on your vehicle we know you have choices, however your business is important to us and we would like to earn it! Simply complete this form below and then print the resulting page and bring it with you to save <font color="#993300"><strong>10% OFF</strong></font> work performed!</font></FONT></p></TD> </TR> <TR> <TD height="16"> </TD> <TD height="16" valign="top"><img src="../images/spacers/blank.gif" width="1" height="15"> </TD> </TR> </TBODY> </TABLE> <p align=center style="margin-top: 0; margin-bottom: 0"><P style="margin-top: 0; margin-bottom: 0"><SPAN style="position: absolute; left: 450px; top: 340; width: 113px; height: 115px"><IMG height=79 src="images/save.gif" vspace=3 width="80"></SPAN></P></DIV> </TD> </TR> <TR> <TD vAlign=top width=513 height="136"> <DIV align="center"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="2%" height="116"><img src="../images/spacers/spacer.gif" width="25" height="35"> </td> <td width="98%"><P style="margin-top: 0; margin-bottom: 0"><IMG height=22 alt="First and last name:" hspace=2 src="images/name.gif" width=143> <INPUT type="text" name="YourName" size="30"> <br> <IMG height=22 alt="Your Email Address:" hspace=2 src="images/email.gif" width=54> <INPUT type="text" name="YourEmail" size="30"><br> <IMG height=22 alt="Phone" hspace=2 src="images/phone.gif" width=54> <INPUT type="text" name="YourPhone" size="26"> </P> </td> </tr> </table> </DIV> </TD> </TR> <TR> <TD vAlign=top width=513 height="12"> <P align="center" style="margin-top: 0; margin-bottom: 0"> <input type=image src="images/click.gif" border=0 name=clickme width="270" height="25"> </TD> </TR> <TR> <TD vAlign=top width=513> <P align="center"><font size="1" color="#000000" face="Arial, Helvetica, sans-serif">After clicking the button, please print your certificate and bring it with you when you visit.</font> </TD> </TR> </TBODY> </TABLE> <TABLE cellSpacing=0 cellPadding=0 width=111% border=0 height="37"> <TBODY> <TR> <TD vAlign=top width=100% bgColor=#444444 height=1><IMG height=1 alt="" src="../images/spacers/blank.gif" width=100%></TD> </TR> <TR> <TD vAlign=top height=2><IMG height=1 alt="spacer" src="../images/spacers/blank.gif" width=1> <div align="center"><img src="../images/spacers/blank.gif" width="1" height="4"><br> <font face="Arial, Helvetica, sans-serif" size="2" color="#666666"> Virtual Certificate</font></div> </TD> </TR> </TBODY> </TABLE> </form> </BODY> </HTML> This is the results page of the submitted form, php page (partial): <HTML><title>Print Auto Repair Coupon</title> <BODY bgColor=#ffffff link="#000099" leftMargin=0 topMargin=0 rightMargin=0 bottomMargin=0 marginwidth="0" marginheight="0"> <TR> <TD vAlign=top width=500 height="26"> <DIV align="center"> <TABLE cellSpacing=0 cellPadding=0 width=500 border=0 bordercolor="#111111"> <TBODY> <TR> <TD width=500 height="40" vAlign=bottom nowrap> <P style="margin-top: 0; margin-bottom: 0" align="center"> <font face="Arial, Helvetica, sans-serif" size="+2"><b> <?php print $YourName; ?><br> <?php print $YourEmail; ?><br> <?php print $YourPhone; ?></b></font></TD> </TR> </TBODY> </TABLE> </DIV></TD> </TR> <TR> <TD vAlign=top height="12"> </TD> </TR> <TR> <TD vAlign=top width=500 height="12"> <div align="center"> <input type=button value="Print Page" onClick="print()"> </div></TD> </TR> </BODY> </HTML> Here is a link to the voucher, please try it to see what I am trying to do: RMS Auto Care When the page loads, click on the link (right in front) Voucher for 10% OFF Auto Repairs! Click here NOW! This is the code I came up with to insert in the html page, but it does not work. I also tried it in the php page and it didn't work either. <? //Declare the variables $recipient = "kitidid@ev1.net"; $subject = "RMS Auto Care Voucher"; $YourName = "YourName"; $YourName = "YourEmail"; $YourPhone = "YourPhone"; $message = "Hi there! My name is $YourName. I just printed the voucher from your website. I will present the voucher for 10% off auto repair. My phone number is $YourPhone and my email is $YourEmail"; $subject=$_POST['subject']; //Contents of form $YourName=$_POST['YourName']; $YourName=$_POST['YourEmail']; $YourPhone=$_POST['YourPhone']; //mail() function sends the mail mail($subject,$YourName,$YourEmail,$YourPhone,$mes sage); ?> Maybe the php code is incorrect, maybe I am putting it in the wrong spot in the page or, or, or....... Your input is greatly appreciated! Kitti Last edited by kittidid : June 21st, 2003 at 12:26 AM. |
|
#2
|
|||
|
|||
|
aww man common,....ya know,...I don't mind that people paste 5 pages of code,....but at least surround all that in code tags man,....
Code:
code tags
__________________
-- Jason |
|
#3
|
|||
|
|||
|
First rule... every important function that allows a return value, please grab that value.
The mail function is a boolean type which means when you call it you can grab its return value as true or false. If the mail command works you will get a return value of true, if not then false is what you will get. Change your call to the mail function to this: Code:
<?php
if (!mail($subject,$YourName,$YourEmail,$YourPhone,$m essage)) {
if (!write_error_log("PROBLEM WITH MAIL()", __LINE__, __FILE__, "/tmp/error.log")) {
print "file permission error";
exit;
}
}
function write_error_log($msg,$line,$file,$dest)
{
setlocale (LC_TIME, 'en_US');
$dt = strftime ("%G%m%d %H:%M:%S", mktime())."\n";
return error_log ("ERROR: $msg - $dt - LINE: $line - FILE: $file\n", 3, $dest);
}
?>
Your code doesn't have to be exactly like this but at least incorporate some sort of error checking and some sort of notification so you know where your problem is. I'm am almost sure your problem is with the mail function though. Check your php.ini for the correct settings.
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. Last edited by laidbak : June 21st, 2003 at 02:38 AM. |
|
#4
|
|||
|
|||
|
php.ini
I don't have a file php.ini. Do I have to have one?
Also I apologize for the long code above! Kitti |
|
#5
|
|||
|
|||
|
php code
Thanks for your help laidbak. Appreciated!
Does this code go in the html page? Kitti Last edited by kittidid : June 21st, 2003 at 03:39 AM. |
|
#6
|
|||
|
|||
|
This is php code and it goes in a file named with a .php extension.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > html form printed to php page |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|