Graag zou ik dit script:
<?
// de functie
function email_validator($email)
{
if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$",$email))
{
$valid = "yes";
}
else
{
$valid = "no";
}
return $valid;
}

// je roept hem als volgt aan
$email = "[email protected]";
$check_email = email_validator($email);

if ($check_email == "yes")
{
echo "Het e-mail adres: $email is oke!<p>";
}
else
{
echo "Het e-mail adres: $email is <b>niet</b> oke!<p>";
}
?>


in willen voegen in dit script:

<?php

$email = $_POST['email'];
$name = $_POST['name'];
$comments = $_POST['comments'];

// your email address
$youremail = "[email protected]";

// field validation
if ($email=="" || $comments=="" || $name=="")

{
print ("All fields are required! Please go back and try again.");
}

else {

// send email
$headers = "From: \"$name\" <$email>\n";
$subject = "Mailformulier www.diabolotrucs.nl";;
$message = "$comments";

mail ("$youremail", "$subject", $message, $headers);
}
?>

Ik heb er bijna geen tot een heel klein beetje verstand van, vandaar dat ik het vraag...

Hopelijk wil iemand het even voor mij doen!!

Gerco
Het is heel simpel:


<?php

// Function check email:
function email_validator($email)
{
    if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$",$email))
    {
        $valid = true;
    }
    else
    {
        $valid = false;
    }
    return $valid;
}

$email = (email_validator($_POST['email']) ? $_POST['email'] : false;
$name = $_POST['name'];
$comments = $_POST['comments']; 

// your email address
$youremail = "[email protected]";

// field validation
if ($email == false)
{
    print("Your email address is invalid");
}
elseif ($email=="" || $comments=="" || $name=="")

{
print ("All fields are required! Please go back and try again.");
}

elseif {

// send email
$headers = "From: \"$name\" <$email>\n";
$subject = "Mailformulier www.diabolotrucs.nl"; 
$message = "$comments";

mail ("$youremail", "$subject", $message, $headers);
} 
?> 
Hij geeft een error op line 50
Parse error: syntax error, unexpected ';' in /var/www/vhosts/diabolotrucs.nl/httpdocs/bedankt.php on line 50

Dat is de eerste regel en de daarop volgende:
$email = (email_validator($_POST['email']) ? $_POST['email'] : false;
$name = $_POST['name'];
$comments = $_POST['comments'];
Dat is nou zo'n fout waar ik gek van wordt :P

Hier onder het goede script (ben bij $email ) dat teken vergeten)


<?php

// Function check email:
function email_validator($email)
{
    if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$",$email))
    {
        $valid = true;
    }
    else
    {
        $valid = false;
    }
    return $valid;
}

$email = (email_validator($_POST['email'])) ? $_POST['email'] : false;
$name = $_POST['name'];
$comments = $_POST['comments']; 

// your email address
$youremail = "[email protected]";

// field validation
if ($email == false)
{
    print("Your email address is invalid");
}
elseif ($email=="" || $comments=="" || $name=="")

{
print ("All fields are required! Please go back and try again.");
}

elseif {

// send email
$headers = "From: \"$name\" <$email>\n";
$subject = "Mailformulier www.diabolotrucs.nl"; 
$message = "$comments";

mail ("$youremail", "$subject", $message, $headers);
} 
?> 
Die fout is nu iig weg! bedankt daarvoor...

Maar nu geeft hij deze fout:
Parse error: syntax error, unexpected '{', expecting '(' in /var/www/vhosts/diabolotrucs.nl/httpdocs/bedankt.php on line 68

Line 68 tot het einde:
elseif {

// send email
$headers = "From: \"$name\" <$email>\n";
$subject = "Mailformulier www.diabolotrucs.nl";;
$message = "$comments";

mail ("$youremail", "$subject", $message, $headers);
}
?>

Weet je misschien daar ook de oplossing voor?

Zou heel mooi zijn! :)

Gerco
bij elseif moet je ook zeggen wat er moet gebeuren
bijv.

<?php
if(1 + 1 = 3)
{
//iets
echo 'optie 1';
}
elseif(1 + 1 = 2)
{
//iets anders
echo 'optie 2';
}
else
{
//nog iets anders
echo 'optie 3';
}

?>

dit zou dus optie 2 uitprinten

Reageren