Contact formulier
Omdat ik zelf niet verder kom heb ik graag de hulp nodig voor een contact formulier.
De HTML basis heb ik al, nu moet deze gecombineerd worden met PHPmailer en krijg het maar niet aan de praat.
Geintereseerd?
Je kan me mailen op: [email protected]
Met vriendelijke groet,
Tonny-Boy Verweij
Wat gaat er mis? Heb je zelf al iets geprobeerd?
Ik had een PHP code, alleen me email verstuurd niet. Het formulier zit goed in elkaar.
Laat eens wat relevate code zien zodat we kunnen zien waar het mis gaat.
Ik had bij Beginnen met PHP al het één en ander geplaatst. Maar kom daar er ook niet uit.
Heb je bij de hostingprovider al eens in de FAQ gekeken? een aantal providers hebben de mailfunctie vanuit PHP uit staan waardoor je naar SMTP zult moeten uitwijken. Ook zijn de juiste instellingen erg belangrijk.
Ik zit bij mijndomein.nl die ondersteunen dat gewoon volgensmij.
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.yourdomain.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.yourdomain.com"; // sets the SMTP server
$mail->Port = 26; // set the SMTP port for the GMAIL server
$mail->Username = "yourname@yourdomain"; // SMTP account username
$mail->Password = "yourpassword"; // SMTP account password
$mail->SetFrom('[email protected]', 'First Last');
$mail->AddReplyTo("[email protected]","First Last");
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$address = "[email protected]";
$mail->AddAddress($address, "John Doe");
$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.yourdomain.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.yourdomain.com"; // sets the SMTP server
$mail->Port = 26; // set the SMTP port for the GMAIL server
$mail->Username = "yourname@yourdomain"; // SMTP account username
$mail->Password = "yourpassword"; // SMTP account password
$mail->SetFrom('[email protected]', 'First Last');
$mail->AddReplyTo("[email protected]","First Last");
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$address = "[email protected]";
$mail->AddAddress($address, "John Doe");
$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
<div id="contact">
<div id="message"></div>
<form method="post" action="/formulierverzenden.php" name="contactform" id="contactform" autocomplete="off">
<fieldset>
<label for="name" accesskey="U"><span class="required">Name</span></label>
<input name="name" type="text" id="name" size="30" title="Name *" class="margin-right" />
<label for="email" accesskey="E"><span class="required">Email</span></label>
<input name="email" type="text" id="email" size="30" title="Email *" />
<label for="comments" accesskey="C"><span class="required">Comments</span></label>
<textarea name="comments" cols="40" rows="3" id="comments" title="Comment *"></textarea>
<input type="submit" class="submit" id="submit" value=" Submit" />
</fieldset>
</form>
<div id="message"></div>
<form method="post" action="/formulierverzenden.php" name="contactform" id="contactform" autocomplete="off">
<fieldset>
<label for="name" accesskey="U"><span class="required">Name</span></label>
<input name="name" type="text" id="name" size="30" title="Name *" class="margin-right" />
<label for="email" accesskey="E"><span class="required">Email</span></label>
<input name="email" type="text" id="email" size="30" title="Email *" />
<label for="comments" accesskey="C"><span class="required">Comments</span></label>
<textarea name="comments" cols="40" rows="3" id="comments" title="Comment *"></textarea>
<input type="submit" class="submit" id="submit" value=" Submit" />
</fieldset>
</form>
Gewijzigd op 11/02/2014 16:11:19 door TonnyBoy Verweij
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
<?php
$message = 'Naam ' . htmlentities($_POST['name']) . '<br/>'
.'Email ' . htmlentities($_POST['email']) . '<br/>'
.'Bericht ' . htmlentities($_POST['comments']) . '<br/>';
$mail->Body($message);
?>
$message = 'Naam ' . htmlentities($_POST['name']) . '<br/>'
.'Email ' . htmlentities($_POST['email']) . '<br/>'
.'Bericht ' . htmlentities($_POST['comments']) . '<br/>';
$mail->Body($message);
?>
Edit: Ik zie nu dat dit in vacatures staat. Als je het wilt laten uitbesteden, geef dan budget, tenzij het vrijwillig is.
Gewijzigd op 11/02/2014 16:21:59 door - Ariën -
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
require_once('/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.tonneurd.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.tonneurd.com"; // sets the SMTP server
$mail->Port = 26; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // SMTP account username
$mail->Password = "------"; // SMTP account password
$mail->SetFrom('[email protected]', 'First Last');
$mail->AddReplyTo("[email protected]","First Last");
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$message = 'Naam ' . htmlentities($_POST['name']) . '<br/>'
.'Email ' . htmlentities($_POST['email']) . '<br/>'
.'Bericht ' . htmlentities($_POST['comments']) . '<br/>';
$mail->Body($message);
$address = "[email protected]";
$mail->AddAddress($address, "John Doe");
$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
require_once('/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.tonneurd.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.tonneurd.com"; // sets the SMTP server
$mail->Port = 26; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // SMTP account username
$mail->Password = "------"; // SMTP account password
$mail->SetFrom('[email protected]', 'First Last');
$mail->AddReplyTo("[email protected]","First Last");
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$message = 'Naam ' . htmlentities($_POST['name']) . '<br/>'
.'Email ' . htmlentities($_POST['email']) . '<br/>'
.'Bericht ' . htmlentities($_POST['comments']) . '<br/>';
$mail->Body($message);
$address = "[email protected]";
$mail->AddAddress($address, "John Doe");
$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
Dus zo moet die kloppen?
EDIT: De submit knop geeft geen actie. Waar kan deze fout uit voortkomen? Uit de html?
Gewijzigd op 11/02/2014 16:27:38 door TonnyBoy Verweij
Je controleert niet of er gePOST is.
- Aar - op 11/02/2014 17:23:08:
Je controleert niet of er gePOST is.
Sorry hoor maar snap er geen knikker meer van, vandaar dat ik het ook hier geplaatst heb.
www.phptuts.nl te bekijken en de voorbeelden uit te proberen.
Of laat het uitbesteden, zoals ik al eerder zei...
Dan raad ik je aan om eens de beginnertutorial van Of laat het uitbesteden, zoals ik al eerder zei...
Gewijzigd op 11/02/2014 17:35:05 door - Ariën -
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
require_once('/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.tonneurd.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.tonneurd.com"; // sets the SMTP server
$mail->Port = 26; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // SMTP account username
$mail->Password = "-----"; // SMTP account password
$mail->SetFrom('[email protected]', 'First Last');
$mail->AddReplyTo("[email protected]","First Last");
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$message = 'Naam ' . htmlentities($_POST['name']) . '<br/>'
.'Email ' . htmlentities($_POST['email']) . '<br/>'
.'Bericht ' . htmlentities($_POST['comments']) . '<br/>';
if(isset($_POST[$name]))
{
if(isset($_POST[$email]))
{
if(isset($_POST[$comments]))
{
$mail->Body($message);
$address = "[email protected]";
$mail->AddAddress($address, "John Doe");
$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
require_once('/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.tonneurd.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.tonneurd.com"; // sets the SMTP server
$mail->Port = 26; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // SMTP account username
$mail->Password = "-----"; // SMTP account password
$mail->SetFrom('[email protected]', 'First Last');
$mail->AddReplyTo("[email protected]","First Last");
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$message = 'Naam ' . htmlentities($_POST['name']) . '<br/>'
.'Email ' . htmlentities($_POST['email']) . '<br/>'
.'Bericht ' . htmlentities($_POST['comments']) . '<br/>';
if(isset($_POST[$name]))
{
if(isset($_POST[$email]))
{
if(isset($_POST[$comments]))
{
$mail->Body($message);
$address = "[email protected]";
$mail->AddAddress($address, "John Doe");
$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
Gewijzigd op 11/02/2014 17:47:12 door TonnyBoy Verweij
Je kan ook lukraak wat PHP-code toevoegen, maar ik heb eigenlijk niet echt het idee dat je mijn advies hebt opgevolgd.