wNkr Posted August 18, 2007 Share Posted August 18, 2007 Hi there! I want to use a dutch e-mail form with which people can subscribe teams for a party we are organizing. The html form code is the following: <FORM METHOD="POST" ACTION="sendmail.php"> <tr><strong>Naam Team:</strong></tr> <br /> <tr><INPUT TYPE="text" NAME="team" SIZE="30"></tr><br /> <tr><strong>Contactpersoon:</strong></tr> <br /> <tr><SELECT NAME="contactpersoon1" SIZE="1"> <OPTION SELECTED>Dhr. <OPTION>Mevr.</SELECT> <INPUT TYPE="text" NAME="contactpersoon2" SIZE="30"></tr><br /> <tr><strong>Aantal:</strong></tr> <br /> <tr><INPUT TYPE="text" NAME="aantal" SIZE="3"></tr><br /> <tr><strong>Adres:</strong></tr> <br /> <tr><INPUT TYPE="text" NAME="adres" SIZE="30"></tr><br /> <tr><strong>Postcode:</strong></tr> <br /> <tr><INPUT TYPE="text" NAME="postcode" SIZE="30"></tr><br /> <tr><strong>Plaats:</strong></tr> <br /> <tr><INPUT TYPE="text" NAME="plaats" SIZE="30"></tr><br /> <tr><strong>Telefoon:</strong></tr ><br /> <tr><INPUT TYPE="text" NAME="telefoon" SIZE="30"></tr><br /> <tr><strong>E-mail:</strong></tr> <br /> <tr><INPUT TYPE="text" NAME="email" SIZE="30"></tr> <INPUT TYPE="submit" value="Verzenden"> <INPUT TYPE="reset"></FORM> I'm wondering if someone can tell me how the 'sendmail.php' file should look like to get this form send an email to me. Thanks in advance wNkr Quote Link to comment https://forums.phpfreaks.com/topic/65597-need-php-code-for-mail-form/ Share on other sites More sharing options...
phpQuestioner Posted August 19, 2007 Share Posted August 19, 2007 This is a very simple example; you may want to make it more complex. sendmail.php <?php $team = addslashes($_POST["team"]); $contactpersoon1 = addslashes($_POST["contactpersoon1"]); $aantal = addslashes($_POST["aantal"]); $adres = addslashes($_POST["adres"]); $postcode = addslashes($_POST["postcode"]); $plaats = addslashes($_POST["plaats"]); $telefoon = addslashes($_POST["telefoon"]); $email = addslashes($_POST["email"]); // I Did Not Include Any Validation // You May Want To Use PHP or You May Want To Validate Client Side with JavaScript $to="you@youremailaddressdomain.com" $from="$email"; $subject="New Member Has Subscribed To Your Party"; $msg="Team: $team\n" . "Contact Person: $contactpersoon1\n" . "Aantal: $aantal\n" . "Adres: $adres\n" . "Post Code: $postcode\n" . "Plaats: $plaats\n" . "Telefoon: $telefoon\n" . "Email: $email\n"; mail($to, $from, $subject, $msg); echo "<font color=red>Thank You - We Have Received You Email</font>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/65597-need-php-code-for-mail-form/#findComment-327928 Share on other sites More sharing options...
wNkr Posted August 19, 2007 Author Share Posted August 19, 2007 Thanks for your reply. But unfortunately it doesn't seem to work. I've used your code as 'sendmail.php', but the only thing happening is that the browser is trying to load sendmail.php. There's no mail sent! The URL of my website is http://www.beachpartytilburg.nl and the form is placed under "Inschrijven". What can be the problem? Quote Link to comment https://forums.phpfreaks.com/topic/65597-need-php-code-for-mail-form/#findComment-328080 Share on other sites More sharing options...
plutomed Posted August 19, 2007 Share Posted August 19, 2007 Have you changed the $to to your email or the e-mail that is being used? Quote Link to comment https://forums.phpfreaks.com/topic/65597-need-php-code-for-mail-form/#findComment-328091 Share on other sites More sharing options...
wNkr Posted August 19, 2007 Author Share Posted August 19, 2007 yes i have Quote Link to comment https://forums.phpfreaks.com/topic/65597-need-php-code-for-mail-form/#findComment-328098 Share on other sites More sharing options...
phpQuestioner Posted August 19, 2007 Share Posted August 19, 2007 I think I may have left a little something out - try this and see if it works now <?php $team = addslashes($_POST["team"]); $contactpersoon1 = addslashes($_POST["contactpersoon1"]); $aantal = addslashes($_POST["aantal"]); $adres = addslashes($_POST["adres"]); $postcode = addslashes($_POST["postcode"]); $plaats = addslashes($_POST["plaats"]); $telefoon = addslashes($_POST["telefoon"]); $email = addslashes($_POST["email"]); // I Did Not Include Any Validation // You May Want To Use PHP or You May Want To Validate Client Side with JavaScript $to="you@youremailaddressdomain.com" $from="From:$email"; $subject="New Member Has Subscribed To Your Party"; $msg="Team: $team\n" . "Contact Person: $contactpersoon1\n" . "Aantal: $aantal\n" . "Adres: $adres\n" . "Post Code: $postcode\n" . "Plaats: $plaats\n" . "Telefoon: $telefoon\n" . "Email: $email\n"; mail($to, $from, $subject, $msg); echo "<font color=red>Thank You - We Have Received You Email</font>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/65597-need-php-code-for-mail-form/#findComment-328238 Share on other sites More sharing options...
wNkr Posted August 19, 2007 Author Share Posted August 19, 2007 replaced the code, but nothing changed as you can see on http://www.beachpartytilburg.nl I saw that you forgot to add 'contactpersoon2' in the php code, while it stands in the html form: <tr><SELECT NAME="contactpersoon1" SIZE="1"> <OPTION SELECTED>Dhr. <OPTION>Mevr.</SELECT> <INPUT TYPE="text" NAME="contactpersoon2" SIZE="30"></tr> could that be causing any problems? Quote Link to comment https://forums.phpfreaks.com/topic/65597-need-php-code-for-mail-form/#findComment-328245 Share on other sites More sharing options...
phpQuestioner Posted August 19, 2007 Share Posted August 19, 2007 ok - if this doesn't work; then I am not sure - might want to check and see if you server/web host has PHP installed on it. Try This <?php @$team = addslashes($_POST['team']); @$contactpersoon1 = addslashes($_POST['contactpersoon1']); @$contactpersoon2 = addslashes($_POST['contactpersoon2']); @$aantal = addslashes($_POST['aantal']); @$adres = addslashes($_POST['adres']); @$postcode = addslashes($_POST['postcode']); @$plaats = addslashes($_POST['plaats']); @$telefoon = addslashes($_POST['telefoon']); @$email = addslashes($_POST['email']); // I Did Not Include Any Validation // You May Want To Use PHP or You May Want To Validate Client Side with JavaScript $header = "From: $email\n"; $subject = "New Member Has Subscribed To Your Party"; $to = "you@youremailaddressdomain.com"; $pfw_message = "team: $team\n" . "contactpersoon1: $contactpersoon1\n" . "contactpersoon2: $contactpersoon2\n" . "aantal: $aantal\n" . "adres: $adres\n" . "postcode: $postcode\n" . "plaats: $plaats\n" . "telefoon: $telefoon\n" . "email: $email\n"; @mail($to, $subject ,$pfw_message ,$header ) ; echo "<font color=red>Thank You - We Have Received You Email</font>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/65597-need-php-code-for-mail-form/#findComment-328247 Share on other sites More sharing options...
wNkr Posted August 19, 2007 Author Share Posted August 19, 2007 We are making improvements. Now I get a notification that the email has been sent, but when I look in my inbox, there are no emails in it ??? even checked it with 2 different email addresses! Quote Link to comment https://forums.phpfreaks.com/topic/65597-need-php-code-for-mail-form/#findComment-328276 Share on other sites More sharing options...
phpQuestioner Posted August 19, 2007 Share Posted August 19, 2007 Gotta tell ya - I do not know what's wrong, but it isn't the code. The first two pieces of code; I wrote from my memory. The third piece of code came from a PHP form processing generator, that I have. So I know it is not the code; might want to check your email spam filter and make sure the email is not being sent to your "Junk" mail folder. If this is not the case; you may want to contact your web hosting and ask them if there is any special requirements for sending/receiving PHP Email. I know that some host require that you "From" address be within your domain (ie: you@yourdomain.com - instead of: you@yahoo.com). Some web host will not allow you to send out PHP Email unless it is this way; I have dealt with web host like that, in the past. Other then that I really do not know why you would not be able to receive the form email (that is; if you have PHP installed on your web host) - Good Luck. Quote Link to comment https://forums.phpfreaks.com/topic/65597-need-php-code-for-mail-form/#findComment-328297 Share on other sites More sharing options...
Northern Flame Posted August 19, 2007 Share Posted August 19, 2007 This will work, change "you@domain.com" to your email address, and you can change the subject, and the html code on the bottom <?php $team = $_POST['team']; $contactpersoon1 = $_POST['contactpersoon1']; $contactpersoon2 = $_POST['contactpersoon2']; $aantal = $_POST['aantal']; $adres = $_POST['adres']; $postcode = $_POST['postcode']; $plaats = $_POST['plaats']; $telefoon = $_POST['telefoon']; $email = $_POST['email']; mail( "you@domain.com", "New Subscriber!", " Team = $team Contact Persoon1 = $contactpersoon1 Contact Persoon2 = $contactpersoon2 Aantal = $aantal Adres = $adres Postcode = $postcode Plaats = $plaats Telefoon = $telefoon Email = $email", "From: $email"); echo ' <html> <head> <title> Thanks For Subscribing </title> </head> <body> <h3>Thanks for contacting us '.$email.',<br> we will review your subscription as soon as<br> possible!<br><br><br><br> -Administration</h3> </body> </html>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/65597-need-php-code-for-mail-form/#findComment-328309 Share on other sites More sharing options...
phpQuestioner Posted August 19, 2007 Share Posted August 19, 2007 The code I provided will work also; it works fine on my server. I know, because I just tested the PHP Code & HTML Form provided and it sent the email right to my email address; without any problems. So you might want to contact your web host; as I stated previously - Good Luck. Quote Link to comment https://forums.phpfreaks.com/topic/65597-need-php-code-for-mail-form/#findComment-328311 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.