Hallo allemaal,
Ik had onlangs een contactformulier gemaakt dat perfect werkte en geen foutmeldingen gaf. Nu sinds enkele dagen krijg ik plots volgende meldingen onder mijn formulier:
PHP Notice: Undefined index: submit in D:\www\7inchrecords.com\www\contact.php on line 28 PHP Notice: Undefined index: submit in D:\www\7inchrecords.com\www\contact.php on line 30 PHP Notice: Undefined index: naam in D:\www\7inchrecords.com\www\contact.php on line 30 PHP Notice: Undefined index: naam in D:\www\7inchrecords.com\www\contact.php on line 45 PHP Notice: Undefined index: mail in D:\www\7inchrecords.com\www\contact.php on line 52 PHP Notice: Undefined index: onderwerp in D:\www\7inchrecords.com\www\contact.php on line 59 PHP Notice: Undefined index: msggs in D:\www\7inchrecords.com\www\contact.php on line 66
Terwijl de form perfect blijft werken, als je ze invult krijg ik mooi een email toe.
Hoe kan ik dit vervelende euvel verhelpen? Hier is de code die ik gebruik:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Where to find us</title>
<link rel="stylesheet" type="text/css" href="sam6.css" >
</head>
<body text="#000000" link="#000000">
<?
// geef e-mail adres op van ontvanger
$mail_ontv = "samuel.coomans@telenet.be";
// is niet 100% !!!
function checkmail($mail)
{
$email_host = explode("@", $mail);
$email_host = $email_host['1'];
$email_resolved = gethostbyname($email_host);
if ($email_resolved != $email_host && eregi("^[0-9a-z]([-_.~]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$",$mail))
$valid = 1;
return $valid;
}
// als er niet op submit is gedrukt, of als er wel op is gedrukt maar niet alles ingevoerd is
if (!$_POST['submit'] || !$_POST['submit'] && (!$_POST['naam'] || !$_POST['mail'] || !checkmail($_POST['mail']) || !$_POST['msggs'] || !$_POST['onderwerp']))
{
if (!$_POST['submit'] && (!$_POST['naam'] || !$_POST['mail'] || !checkmail($_POST['mail']) || !$_POST['msggs'] || !$_POST['onderwerp']))
{
echo "You forget to fill out your name, email, subject or message. It is also possible that";
echo "you used a wrong email address.<p>";
}
// form + tabel
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" height=\"100%\">";
echo "<tr><td align=\"center\" valign=\"middle\">";
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" ALIGN=\"center\">";
echo "<form method=\"POST\" ACTION=\"" . $_SERVER['PHP_SELF'] . "\">";
// naam
echo "<tr><td>Name:</td></tr>";
echo "<tr><td><input type=\"text\" name=\"naam\" value=\"" . $_POST['naam'] . "\"></td></tr>";
// space
echo "<tr><td> </td></tr>";
// mail
echo "<tr><td>E-mail:</td></tr>";
echo "<tr><td><input type=\"text\" name=\"mail\" value=\"" . $_POST['mail'] . "\"></td></tr>";
// space
echo "<tr><td> </td></tr>";
// mail
echo "<tr><td>Subject:</td></tr>";
echo "<tr><td><input type=\"text\" name=\"onderwerp\" value=\"" . $_POST['onderwerp'] . "\"></td></tr>";
// space
echo "<tr><td> </td></tr>";
// mail
echo "<tr><td>Message:</td></tr>";
echo "<tr><td><TEXTAREA name=\"msggs\" ROWS=\"6\" COLS=\"45\">" . htmlentities($_POST['msggs']) . "</TEXTAREA></td></tr>";
// space
echo "<tr><td> </td></tr>";
// button
echo "<tr><td> </td></tr>";
echo "<tr><td><input type=\"submit\" name=\"submit\" value=\"Send\"></td></tr>";
// sluit form + tabel
echo "</form>";
echo "</table>";
echo "</td></tr>";
echo "</table>";
}
// versturen naar
else
{
// set datum
$datum = date("d.m.Y H:i");
// set ip
$ip = $_SERVER['REMOTE_ADDR'];
$inhoud_mail = "===================================================\n";
$inhoud_mail .= "Ingevulde contact formulier\n";
$inhoud_mail .= "===================================================\n\n";
$inhoud_mail .= $_SERVER['SCRIPT_URI'] . "\n\n";
$inhoud_mail .= "Naam: " . $_POST['naam'] . "\n";
$inhoud_mail .= "E-mail adres: " . $_POST['mail'] . "\n";
$inhoud_mail .= "Bericht:\n";
$inhoud_mail .= $_POST['msggs'] . "\n\n";
$inhoud_mail .= "Verstuurd op " . $datum . " via het ip " . $ip . "\n\n";
$inhoud_mail .= "===================================================\n\n";
// --------------------
// spambot protectie
// ------
// van de tutorial: http://www.phphulp.nl/php/tutorials/10/340/
// ------
$headers = "From: " . $_POST['naam'] . " <" . $_POST['mail'] . ">";
$headers = stripslashes($headers);
$headers = str_replace("\n", "", $headers); // Verwijder \n
$headers = str_replace("\r", "", $headers); // Verwijder \r
$headers = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $headers)); // Slashes van quotes
$_POST['onderwerp'] = str_replace("\n", "", $_POST['onderwerp']); // Verwijder \n
$_POST['onderwerp'] = str_replace("\r", "", $_POST['onderwerp']); // Verwijder \r
$_POST['onderwerp'] = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $_POST['onderwerp'])); // Slashes van quotes
mail($mail_ontv, $_POST['onderwerp'], $inhoud_mail, $headers);
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" height=\"100%\">";
echo "<tr><td align=\"center\" valign=\"middle\">";
echo "<h2>Your email has been sent</h2>";
echo "<p>Thanks for sending your message, <br>we will respond as soon as possible.</p>";
echo '<A HREF="http://www.7inchrecords.com/home.htm" target="main">Click here to go back to my homepage</A>';
echo "</td></tr>";
echo "</table>";
}
?>
</body>
</html>
Ik had onlangs een contactformulier gemaakt dat perfect werkte en geen foutmeldingen gaf. Nu sinds enkele dagen krijg ik plots volgende meldingen onder mijn formulier:
PHP Notice: Undefined index: submit in D:\www\7inchrecords.com\www\contact.php on line 28 PHP Notice: Undefined index: submit in D:\www\7inchrecords.com\www\contact.php on line 30 PHP Notice: Undefined index: naam in D:\www\7inchrecords.com\www\contact.php on line 30 PHP Notice: Undefined index: naam in D:\www\7inchrecords.com\www\contact.php on line 45 PHP Notice: Undefined index: mail in D:\www\7inchrecords.com\www\contact.php on line 52 PHP Notice: Undefined index: onderwerp in D:\www\7inchrecords.com\www\contact.php on line 59 PHP Notice: Undefined index: msggs in D:\www\7inchrecords.com\www\contact.php on line 66
Terwijl de form perfect blijft werken, als je ze invult krijg ik mooi een email toe.
Hoe kan ik dit vervelende euvel verhelpen? Hier is de code die ik gebruik:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Where to find us</title>
<link rel="stylesheet" type="text/css" href="sam6.css" >
</head>
<body text="#000000" link="#000000">
<?
// geef e-mail adres op van ontvanger
$mail_ontv = "samuel.coomans@telenet.be";
// is niet 100% !!!
function checkmail($mail)
{
$email_host = explode("@", $mail);
$email_host = $email_host['1'];
$email_resolved = gethostbyname($email_host);
if ($email_resolved != $email_host && eregi("^[0-9a-z]([-_.~]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$",$mail))
$valid = 1;
return $valid;
}
// als er niet op submit is gedrukt, of als er wel op is gedrukt maar niet alles ingevoerd is
if (!$_POST['submit'] || !$_POST['submit'] && (!$_POST['naam'] || !$_POST['mail'] || !checkmail($_POST['mail']) || !$_POST['msggs'] || !$_POST['onderwerp']))
{
if (!$_POST['submit'] && (!$_POST['naam'] || !$_POST['mail'] || !checkmail($_POST['mail']) || !$_POST['msggs'] || !$_POST['onderwerp']))
{
echo "You forget to fill out your name, email, subject or message. It is also possible that";
echo "you used a wrong email address.<p>";
}
// form + tabel
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" height=\"100%\">";
echo "<tr><td align=\"center\" valign=\"middle\">";
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" ALIGN=\"center\">";
echo "<form method=\"POST\" ACTION=\"" . $_SERVER['PHP_SELF'] . "\">";
// naam
echo "<tr><td>Name:</td></tr>";
echo "<tr><td><input type=\"text\" name=\"naam\" value=\"" . $_POST['naam'] . "\"></td></tr>";
// space
echo "<tr><td> </td></tr>";
echo "<tr><td>E-mail:</td></tr>";
echo "<tr><td><input type=\"text\" name=\"mail\" value=\"" . $_POST['mail'] . "\"></td></tr>";
// space
echo "<tr><td> </td></tr>";
echo "<tr><td>Subject:</td></tr>";
echo "<tr><td><input type=\"text\" name=\"onderwerp\" value=\"" . $_POST['onderwerp'] . "\"></td></tr>";
// space
echo "<tr><td> </td></tr>";
echo "<tr><td>Message:</td></tr>";
echo "<tr><td><TEXTAREA name=\"msggs\" ROWS=\"6\" COLS=\"45\">" . htmlentities($_POST['msggs']) . "</TEXTAREA></td></tr>";
// space
echo "<tr><td> </td></tr>";
// button
echo "<tr><td> </td></tr>";
echo "<tr><td><input type=\"submit\" name=\"submit\" value=\"Send\"></td></tr>";
// sluit form + tabel
echo "</form>";
echo "</table>";
echo "</td></tr>";
echo "</table>";
}
// versturen naar
else
{
// set datum
$datum = date("d.m.Y H:i");
// set ip
$ip = $_SERVER['REMOTE_ADDR'];
$inhoud_mail = "===================================================\n";
$inhoud_mail .= "Ingevulde contact formulier\n";
$inhoud_mail .= "===================================================\n\n";
$inhoud_mail .= $_SERVER['SCRIPT_URI'] . "\n\n";
$inhoud_mail .= "Naam: " . $_POST['naam'] . "\n";
$inhoud_mail .= "E-mail adres: " . $_POST['mail'] . "\n";
$inhoud_mail .= "Bericht:\n";
$inhoud_mail .= $_POST['msggs'] . "\n\n";
$inhoud_mail .= "Verstuurd op " . $datum . " via het ip " . $ip . "\n\n";
$inhoud_mail .= "===================================================\n\n";
// --------------------
// spambot protectie
// ------
// van de tutorial: http://www.phphulp.nl/php/tutorials/10/340/
// ------
$headers = "From: " . $_POST['naam'] . " <" . $_POST['mail'] . ">";
$headers = stripslashes($headers);
$headers = str_replace("\n", "", $headers); // Verwijder \n
$headers = str_replace("\r", "", $headers); // Verwijder \r
$headers = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $headers)); // Slashes van quotes
$_POST['onderwerp'] = str_replace("\n", "", $_POST['onderwerp']); // Verwijder \n
$_POST['onderwerp'] = str_replace("\r", "", $_POST['onderwerp']); // Verwijder \r
$_POST['onderwerp'] = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $_POST['onderwerp'])); // Slashes van quotes
mail($mail_ontv, $_POST['onderwerp'], $inhoud_mail, $headers);
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" height=\"100%\">";
echo "<tr><td align=\"center\" valign=\"middle\">";
echo "<h2>Your email has been sent</h2>";
echo "<p>Thanks for sending your message, <br>we will respond as soon as possible.</p>";
echo '<A HREF="http://www.7inchrecords.com/home.htm" target="main">Click here to go back to my homepage</A>';
echo "</td></tr>";
echo "</table>";
}
?>
</body>
</html>