inherit
58740
0
Aug 20, 2024 7:29:21 GMT -8
®i©hie
I'm not very active here anymore thanks to my full-time job. - 12/27/23
14,036
September 2005
soe
|
Post by ®i©hie on Dec 10, 2009 16:20:14 GMT -8
Hi, can someone give me a really simple easy to understand php code for an email form? i can host the php myself.
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Dec 10, 2009 17:36:02 GMT -8
contact.php and send_contact.php need to be created.
Contact.php code:
<table width="400" border="0" align="center" cellpadding="3" cellspacing="1"> <tr> <td><strong>Contact Form </strong></td> </tr> </table>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1"> <tr> <td><form name="form1" method="post" action="send_contact.php"> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td width="16%">Subject</td> <td width="2%">:</td> <td width="82%"><input name="subject" type="text" id="subject" size="50"></td> </tr> <tr> <td>Detail</td> <td>:</td> <td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td> </tr> <tr> <td>Name</td> <td>:</td> <td><input name="name" type="text" id="name" size="50"></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input name="customer_mail" type="text" id="customer_mail" size="50"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td> </tr> </table> </form> </td> </tr> </table>
Send_contact.php:
<?php // Contact subject $subject ="$subject"; // Details $message="$detail";
// Mail of sender $mail_from="$customer_mail"; // From $header="from: $name <$mail_from>";
// Enter your email address $to ='someone@somewhere.com';
$send_contact=mail($to,$subject,$message,$header);
// Check, if message sent to your email // display message "We've recived your information" if($send_contact){ echo "We've recived your contact information"; } else { echo "ERROR"; } ?>
Merry Christmas! -iChristmas
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Dec 10, 2009 19:46:23 GMT -8
You do realize that this line: $subject ="$subject"; Doesn't do anything?
Also: $message="$detail"; You might as well just rename $detail to $message and get rid of the extra variable. Same for: $mail_from="$customer_mail";
|
|
inherit
100824
0
May 13, 2012 5:37:49 GMT -8
Michael
14,585
March 2007
wrighty
|
Post by Michael on Dec 11, 2009 1:51:39 GMT -8
Er... That wouldn't work... unless $_POST['...'] has become optional overnight?
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Dec 11, 2009 12:34:49 GMT -8
Some servers do it. Not all do, and it's good to not assume that the server does. But I didn't feel like rewriting the entire thing, as there are quite a bit of problems with the code. >_>
|
|
inherit
77753
0
Jul 18, 2024 12:23:50 GMT -8
Bob
2,623
April 2006
bobbyhensley
|
Post by Bob on Dec 13, 2009 1:33:34 GMT -8
contact.php and send_contact.php need to be created. Contact.php code: <table width="400" border="0" align="center" cellpadding="3" cellspacing="1"> <tr> <td><strong>Contact Form </strong></td> </tr> </table>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1"> <tr> <td><form name="form1" method="post" action="send_contact.php"> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td width="16%">Subject</td> <td width="2%">:</td> <td width="82%"><input name="subject" type="text" id="subject" size="50"></td> </tr> <tr> <td>Detail</td> <td>:</td> <td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td> </tr> <tr> <td>Name</td> <td>:</td> <td><input name="name" type="text" id="name" size="50"></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input name="customer_mail" type="text" id="customer_mail" size="50"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td> </tr> </table> </form> </td> </tr> </table>
Send_contact.php: <?php // Contact subject $subject ="$subject"; // Details $message="$detail";
// Mail of sender $mail_from="$customer_mail"; // From $header="from: $name <$mail_from>";
// Enter your email address $to ='someone@somewhere.com';
$send_contact=mail($to,$subject,$message,$header);
// Check, if message sent to your email // display message "We've recived your information" if($send_contact){ echo "We've recived your contact information"; } else { echo "ERROR"; } ?>
Merry Christmas! -iChristmas EGPCS superglobals are bad. Bad enough that the default PHP configuration gets shipped with them disabled, and has been that way since 4.2.0. I'd recommend you steer clear of them for two reasons. One being the simple fact that most servers will have them disabled and the second being that they're quite possibly the most insecure feature PHP has available.
|
|