Hi,
i'm building a mailing script and i'm having a problem with my code...
I've putted this code in my script to view where the problem occurs: (read on the forum)
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
And i've got this error:
Notice: Undefined index: verzendbutton in /home/stevenaert/domains/winmania.be/public_html/php-boek/bestanden/mailinglijst.php on line 15
Notice: Undefined index: verzendbutton in /home/stevenaert/domains/winmania.be/public_html/php-boek/bestanden/mailinglijst.php on line 18
CODE:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
function valid_mail ($str){
return (ereg ('(^[0-9a-zA-Z_\.-]{1,}@([0-9a-zA-Z_\-]{1,}\.[0-9a-zA-Z_\-]{2,}$)', $str));
}
?>
<html>
<head>
<title>Op de hoogte blijven</title>
</head>
<body>
<?php
if ($_POST['verzendbutton'] != "verzenden" || !valid_mail($_POST['mailadres'])){
echo "<h1>Aanmelden voor onze mailinglist</h1>";
echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">";
if ($_POST['verzendbutton'] && !valid_mail($_POST['mailadres'])){
echo "<font color=\"red\">Vul hier een geldig emailadres in aub!</font>";
}
?>
Email: <input type="text" name="mailadres" value="<?php echo $_POST['mailadres'] ?>"><br>
<input type="submit" value="verzenden" name"verzendbutton" >
</form>
<?php
} else {
// schrijf bestand
$bestandsnaam ="mailadressen.txt";
$filehandle = fopen($bestandsnaam, "a");
fwrite($filehandle, $_POST['mailadres']."\n");
fclose ($filehandle);
echo "<br><p>Bedankt, u bent aangemeld op ".$_POST['mailadres']."<br>";
}
?>
</body>
</html>
Somebody who can help me out? Thx