Hi,
i'm new to the forum and to PhP... I'm learning from a book, but can't find an answer by the publisher... It's about a simple contactform i'm building.... I can't figure it out what i'm doing wrong. Before i made adjustments to the script (without checking email and name) everything worked fine... So it's working on my server but i can't find the mistake i made 🙂
ERROR:
Parse error: syntax error, unexpected T_STRING in /home/stevenaert/domains/winmania.be/public_html/php-boek/formulier/formulier.php on line 41
Code:
<html>
<head>
<title>Mailformulier</title>
<link href="../php-boek/formulier.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="container">
<div class="top"></div>
<div class="content">
<div class="text">
<?php
ini_set("SMTP", "smtp.telenet.be");
ini_set("smtp_port", 25);
ini_set("sendmail_from", "emailadres");//Aanpassen email adres
$to= "emailadres";//Aanpassen email adres
//Controle functies (naam en emailadres)
function valid_mail ($str){
return (ereg ('(^[0-9a-zA-Z_\.-]{1,}@([0-9A-ZA-Z_\-]{1,})\.)+[0-9a-zA-Z_\-]{2,}$)', $str));
}
function valid_name ($str){
return (ereg('^[A-Za-z. -]+$', $str));
}
$_POST["naam"] = ucfirst($_POST["naam"]);
if ($_POST["verzendbutton"] != "verzenden" || !valid_name($_POST["naam"]) || !valid_mail($_POST["mailadres"]) || !$_POST["reactie"]){//Dus als het formulier leeg is
// || = shift alt L
?>
<form action="formulier.php" method="post">
<?php
if ($_POST["verzendbutton"] && !valid_name($_POST["naam"])){
echo "<p class=\"warning\">Vul hier uw naam correct in!</p>";
}
?>
Naam: <input type="text" name="naam" value="<?php echo $_POST["naam"] ?>"><br>
<?php
if ($_POST["verzendbutton"] && !valid_mail($_POST["mailadres"])){
echo "<p class=\"warning\">Vul hier een geldig email adres in!</p>";
}
?>
E-mail: <input type ="text" name="mailadres" value="<?php echo $_POST["mailadres"] ?>"><br>
<?php
if ($_POST["verzendbutton"] && !$_POST["reactie"]) {
echo "<p class=\"warning\">Vul hier uw bericht in!</p>";
}
?>
<?php
Uw reactie: <textarea cols="30" rows="4" name="reactie"><?php echo $_POST["reactie"] ?></textarea>
<input type="submit" value="verzenden" name="verzendbutton">
</form>
<?php
} else {// in alle andere gevallen, verzenden dus
$boodschap = "Naam: ".$_POST["naam"]."\nCommentaar: ".$_POST["reactie"];
mail ($to, "Bericht van de website!", $boodschap);
mail ($_POST["mailadres"], "Uw bericht", "Bedankt voor je aanvraag!\nOnderstaande informatie is ons toegezonden.\n".$boodschap);
echo "Bedankt ".$_POST["naam"].", fijn dat je mee wilde doen!";
}
?>
</div>
</div>
<div class="bottom">
</div>
</div>
</body>
</html>
Somebody who can help me out?
Thx