Jump to content

need PHP code for mail form!


wNkr

Recommended Posts

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

Link to comment
Share on other sites

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>";

?>

 

Link to comment
Share on other sites

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>";

?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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>";

?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>';
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.