Formmail Script PHP
Ik heb het een en ander al door gezocht maar kon het juiste antwoord niet vinden.
Ik heb een Contactformulier aangemaakt en een email script PHP om het te verzenden.
Het verzenden lukt, ik krijg het bericht binnen, maar zonder enige inhoud...
Hieronder de Contact formulier:
Quote:
<form action="sendmail.php" method="post">
<p>Choose a Category</p>
<SELECT NAME="category">
<option value="Server">Server
<option value="Forum">Forum
<option value="Website">Website
<option value="Other">Other
</select>
<p>Your Name:</p>
<input type="name">
<p>Your E-mail:</p>
<input type="mail">
<p>Your comment:</p>
<textarea name="comment" rows="7" cols="40">
</textarea>
<br>
<input type="submit" value="Send Message"><input type="reset" value="Clear">
</form>
<p>Choose a Category</p>
<SELECT NAME="category">
<option value="Server">Server
<option value="Forum">Forum
<option value="Website">Website
<option value="Other">Other
</select>
<p>Your Name:</p>
<input type="name">
<p>Your E-mail:</p>
<input type="mail">
<p>Your comment:</p>
<textarea name="comment" rows="7" cols="40">
</textarea>
<br>
<input type="submit" value="Send Message"><input type="reset" value="Clear">
</form>
Het Email script PHP:
Quote:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
// your email address
$youremail = "[email protected]";
// field validation
if ($mail=="" || $comment=="" || $name=="")
{
print ("All fields are required! Please go back and try again.");
}
else {
// send email
$headers = "From: \"$name\" <$email>\n";
$subject = "Feedback Form";
$message = "$comments";
mail ("$youremail", "$subject", $message, $headers);
print ("Thank you $name, your email has been sent.");
}
?>
// your email address
$youremail = "[email protected]";
// field validation
if ($mail=="" || $comment=="" || $name=="")
{
print ("All fields are required! Please go back and try again.");
}
else {
// send email
$headers = "From: \"$name\" <$email>\n";
$subject = "Feedback Form";
$message = "$comments";
mail ("$youremail", "$subject", $message, $headers);
print ("Thank you $name, your email has been sent.");
}
?>
Alvast hartelijk dank voor de hulp.
Ivan Heerkens
Gewijzigd op 24/09/2011 22:22:55 door Ivan Heerkens
$message = "$comments";
comment is niet hetzelfde als comments
Gewijzigd op 24/09/2011 22:25:39 door Ozzie PHP
Ozzie PHP op 24/09/2011 22:24:22:
<textarea name="comment" rows="7" cols="40">
$message = "$comments";
comment is niet hetzelfde als comments
$message = "$comments";
comment is niet hetzelfde als comments
Dit is nu aangepast, maar als ik nu wil verzenden krijg ik:
All fields are required! Please go back and try again.
Ik heb alles ingevuld, zeker weten!
moet zijn
if ($mail=="" || $comments=="" || $name=="")
Staat dat niet in verbinding met die textarea die Comment heet? Zonder S ?
of je gebruikt overal "comment", of je gebruikt overal "comments"... als het maar overal hetzelfde is.
Helaas werkt het nog steeds niet...
Nog altijd
All fields are required! Please go back and try again.
<textarea name="comment" rows="7" cols="40">
if ($mail=="" || $comment=="" || $name=="")
$message = "$comment";
Klopt allemaal, Ja
heb je een voorbeeld online staan?
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
// your email address
$youremail = "[email protected]";
// field validation
if ($_POST['mail']=="" || $_POST['comment']=="" || $_POST['name']=="")
{
print ("All fields are required! Please go back and try again.");
}
else {
// send email
$headers = "From: \"$_POST['name']\" <$_POST['mail']>\n";
$subject = "Feedback Form";
$message = "$_POST['comment']";
mail ("$youremail", "$subject", $message, $headers);
print ("Thank you $name, your email has been sent.");
}
?>
// your email address
$youremail = "[email protected]";
// field validation
if ($_POST['mail']=="" || $_POST['comment']=="" || $_POST['name']=="")
{
print ("All fields are required! Please go back and try again.");
}
else {
// send email
$headers = "From: \"$_POST['name']\" <$_POST['mail']>\n";
$subject = "Feedback Form";
$message = "$_POST['comment']";
mail ("$youremail", "$subject", $message, $headers);
print ("Thank you $name, your email has been sent.");
}
?>
Maar nu krijg ik:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /public/sites/www.minedown.net/sendmail.php on line 16
Dat is :
$headers = "From: \"$_POST['name']\" <$_POST['mail']>\n";
Gewijzigd op 24/09/2011 22:48:38 door Ozzie PHP
$message = "$_POST['comment']";
$message = $_POST['comment'];
Nu geen errors meer, maar weer die:
All fields are required! Please go back and try again.
Toevoeging op 24/09/2011 22:55:36:
plaats je complete php code eens
Heb het op dit moment zo:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
// your email address
$youremail = "[email protected]";
// field validation
if ($_POST['mail']=="" || $_POST['comment']=="" || $_POST['name']=="")
{
print ("All fields are required! Please go back and try again.");
}
else {
// send email
$headers = 'From: "' . $_POST['name'] . '" <' . $_POST['mail'] . '>' . "\n";
$subject = "Contact Form";
$message = $_POST['comment'];
mail ("$youremail", "$subject", $message, $headers);
print ("Thank you $name, your email has been sent.");
}
?>
// your email address
$youremail = "[email protected]";
// field validation
if ($_POST['mail']=="" || $_POST['comment']=="" || $_POST['name']=="")
{
print ("All fields are required! Please go back and try again.");
}
else {
// send email
$headers = 'From: "' . $_POST['name'] . '" <' . $_POST['mail'] . '>' . "\n";
$subject = "Contact Form";
$message = $_POST['comment'];
mail ("$youremail", "$subject", $message, $headers);
print ("Thank you $name, your email has been sent.");
}
?>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<form action="sendmail.php" method="post">
<p>Choose a Category</p>
<SELECT NAME="category">
<option value="Server">Server
<option value="Forum">Forum
<option value="Website">Website
<option value="Other">Other
</select>
<p>Your Name:</p>
<input type="text" value="name">
<p>Your E-mail:</p>
<input type="text" value="mail">
<p>Your comment:</p>
<textarea value="comment" rows="7" cols="40">
</textarea>
<br>
<input type="submit" value="Send Message"><input type="reset" value="Clear">
</form>
<p>Choose a Category</p>
<SELECT NAME="category">
<option value="Server">Server
<option value="Forum">Forum
<option value="Website">Website
<option value="Other">Other
</select>
<p>Your Name:</p>
<input type="text" value="name">
<p>Your E-mail:</p>
<input type="text" value="mail">
<p>Your comment:</p>
<textarea value="comment" rows="7" cols="40">
</textarea>
<br>
<input type="submit" value="Send Message"><input type="reset" value="Clear">
</form>
Ik heb het overgenomen van hierboven, maar nog altijd hetzelfde...
All fields are required! Please go back and try again.
ook komt er nu de value in de tekstveld te staan op de website...
--> www.minedown.net/form.html
Gewijzigd op 24/09/2011 23:08:31 door Ivan Heerkens