Topic: PHP forms - a few questions (Read 1112 times)
Supreme Overlord
Gender:
Posts: 149
1018 credits Members referred : 0
« on: Feb 09, 2007, 07:58:49 PM »
Hi all, I am working on building a PHP form on my website. It is a long form and I need it to email to me using PhP. I would also like to format it nice in the email I will receive. My form has, text areas, radio buttons, check boxes, etc.
I am looking for a good tutorial (free) or someone to give me some pointer.
Any help would be appreciated.
Thanks
Global Moderator
Internet Junkie
Gender:
Posts: 1807
9006 credits Members referred : 6
« Reply #1 on: Feb 09, 2007, 08:45:13 PM »
Code:
<?php mail($emailaddress,$subject,$message)
will send the e-mail. You can format the message any way you want and store it in the $message variable:
Code:
<?php $message = " A form has just been submitted by $name from $location.
His favorite color is: $color and his lucky number is $luckynum.
Have a nice day!";
where the variables used in the message are the variables used in the form. Hope this helps!
« Last Edit: Feb 09, 2007, 08:48:53 PM by Mind_nl »
Supreme Overlord
Gender:
Posts: 149
1018 credits Members referred : 0
« Reply #5 on: Feb 13, 2007, 05:49:33 PM »
Can you give me a more detailed example? I am still confused. I feel like I am just missing something. I'm still sick, so maybe that's it. But I feel silly b/c I know that the information I am looking for is just right there on the tip of my consciousness.
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 8116
41653 credits Members referred : 3
« Reply #6 on: Feb 13, 2007, 06:00:44 PM »
Create a php file and write this :
Code:
<?php echo '<form method="get" action="' . $_SERVER['PHP_SELF'] . '"> <input type="text" name="variable1"></input> <input type="text" name="variable2"></input> <input type="submit"></input> </form> '; if ( !empty($_GET['variable1']) ){ echo '<pre>This is the $_GET array as it posted through the form :<br />'; var_dump($_GET); echo '</pre>'; } ?>
This example will send with email to webmaster@example.com whatever you put in the form. You can change the form to whatever you like and it will still work.
This example will send with email to webmaster@example.com whatever you put in the form. You can change the form to whatever you like and it will still work.
Supreme Overlord
Gender:
Posts: 149
1018 credits Members referred : 0
« Reply #15 on: Feb 13, 2007, 07:10:03 PM »
Happily....
Code:
<?php echo '<form method="get" action="' . $_SERVER['PHP_SELF'] . '"> <table border="0"> <tr> <td>Name:*</td> <td><input type="text" name="Name"></td> </tr> <tr> <td>Company:</td> <td><input type="text" name="Company"></td> </tr> <tr> <td>Title:</td> <td><input type="text" name="Title"></td> </tr> <tr> <td>Contact Number:</td> <td><input type="text" name="Number"></td> </tr> <tr> <td>Email:*</td> <td><input type="text" name="Email"></td> </tr> </table> <hr> <b>Requesting a Quote for:</b><br> <table border="0" cellspacing="10px"> <tr> <td><input type="radio" name="QuoteType" value="Print_WO"> Print Design without printing</td> <td><input type="radio" name="QuoteType" value="Web_W"> Web Design with hosting & domain name</td> </tr> <tr> <td><input type="radio" name="QuoteType" value="Print_W"> Print Design with printing</td> <td><input type="radio" name="QuoteType" value="Web_WO"> Web Design without hosting & domain name</td> </tr> </table> <hr> <h3>Print Design</h3> <p>Please complete this section if you would like a print design quote.</p> Item being quoted:<br> <table border="0" cellspacing="10px"> <tr> <td><input type="radio" name="PrintItemType" value="BC"></td> <td>Business Card</td> <td><input type="radio" name="PrintItemType" value="Flyer"></td> <td>Flyer</td> </tr> <tr> <td><input type="radio" name="PrintItemType" value="2FB"></td> <td>2-Fold Brochure</td> <td><input type="radio" name="PrintItemType" value="3FB"></td> <td>3-Fold Brochure</td> </tr> <tr> <td><input type="radio" name="PrintItemType" value="PC"></td> <td>Post Card</td> <td><input type="radio" name="PrintItemType" value="Sign"></td> <td>Signs</td> </tr> <tr> <td><input type="radio" name="PrintItemType" value="PA"></td> <td>Publication Advertisment, <i>we cannot provide printing prices on this item</i>.</td> <td><input type="radio" name="PrintItemType" value="Other"></td> <td>Other, <i>Please indicate in comment box what type of item you are having quoted</i></td>
</tr> </table> <br> Colors:<br> If you are quoting pricing for printing please be sure to identify the colors you would like to use if you choose 2 or 3 colors in the comment box.<br> <table border="0" cellspacing="10px"> <tr> <td><input type="radio" name="Color" value="CMYK"></td> <td>Full Color (CMYK)</td> <td><input type="radio" name="Color" value="2"></td> <td>2 Colors</td> </tr> <tr> <td><input type="radio" name="Color" value="BW"></td> <td>Black & White or Grey Scale</td> <td><input type="radio" name="Color" value="3"></td> <td>3 Colors</td> </tr> </table> <br> Answer the below question only if you would chose to have printing priced also.<br> Quanity: <input type="text" name="Quanity1"> <input type="text" name="Quanity2"><br> <br> <hr> <h3>Web Design</h3> <p>Please complete this section if you would like a web design quote.</p> Number of Pages on Site: <input type="text" name="Pages"><br> <br> Maintaince Package:<br> <table border="0" cellspacing="10px"> <tr> <td><input type="radio" name="maint" value="Weekly"> </td> <td>Weekly</td> <td><input type="radio" name="maint" value="Monthly"> </td> <td>Monthly</td> </tr> <tr> <td><input type="radio" name="maint" value="AN"> </td> <td>As Needed</td> <td><input type="radio" name="maint" value="None"> </td> <td>None, I will maintain my own site</td> </tr> </table> <br> Online Features: <br> <table border="0" cellspacing="10px"> <tr> <td><input type="checkbox" name="OnlineFeatures" value="PhotoAlbum"></td> <td>Photo Album </td> <td><input type="checkbox" name="OnlineFeatures" value="ScrollingImages"></td> <td>Scrolling Images </td> <td><input type="checkbox" name="OnlineFeatures" value="DDMenu"></td> <td>Drop Down Menu </td> </tr> <tr> <td><input type="checkbox" name="OnlineFeatures" value="SS"></td> <td>Style Switcher <br><i>Please include how <br>many syles you need</i> </td> <td><input type="checkbox" name="OnlineFeatures" value="ShoppingCart"></td> <td>Shopping Cart </td> <td><input type="checkbox" name="OnlineFeatures" value="GB"></td> <td>Guest Book </td> </tr> <tr> <td><input type="checkbox" name="OnlineFeatures" value="Contact"></td> <td>Contact Form </td> <td><input type="checkbox" name="OnlineFeatures" value="Music"></td> <td>Music </td> <td><input type="checkbox" name="OnlineFeatures" value="Form"></td> <td>Form <br>(like this one) </td> </tr> <tr> <td><input type="checkbox" name="OnlineFeatures" value="PWP"></td> <td>Password Protection </td> <td><input type="checkbox" name="OnlineFeatures" value="Admin"></td> <td>Administrative Back end </td> <td><input type="checkbox" name="OnlineFeatures" value="RSS"></td> <td>RSS Feed </td> </tr> <tr> <td colspan="1"><input type="checkbox" name="OnlineFeatures" value="Other"><br></td> <td colspan="5">Other <br><i>Please specify what type feature you are looking for in the comment box.</i> </td>
</tr> </table> <hr> <h3>Comments</h3> <p>Please give us any information you feel is important, or we have requested in the comment box below so you can recieve the most accurte quote available.</p> <TEXTAREA NAME="feedback" ROWS=15 COLS=100></TEXTAREA> <br><br> <input type="submit" value="Submit"> <input type="reset" value="Reset"> </form>'; if ( count($_GET) ){ $mail = ''; foreach ( $_GET as $var => $val ) $mail .= $var . ' -> ' . $val . "\n"; mail( 'myemail@myhost.com', 'Free Quote Request', $mail ); } ?>
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 8116
41653 credits Members referred : 3
« Reply #16 on: Feb 13, 2007, 07:15:11 PM »
This is because you have the same name for all the check boxes so the variables are overwritten.