Hi all,
I have this form page as sidees.php file that sends to itself but it shows the error “You have introducted an invalid code. Please click here and try again”
as the code is not present. How do I make this conditional? Thanks!
<?php
$lastpage = $_SERVER['HTTP_REFERER'];
if (($_SESSION['6_letters_code'] == $_POST['6_letters_code']) && !empty($_SESSION['6_letters_code'])) {
$error = FALSE;
if (!preg_match('/\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*/', $email)) {
echo '<h4>Invalid email address</h4>';
$error = TRUE;
}
if ($name == '') {
echo '<h4>No name</h4>';
$error = TRUE;
}
if ($email_subject == '') {
echo '<h4>No subject</h4>';
$error = TRUE;
}
if ($message == '') {
echo '<h4>No message</h4>';
$error = TRUE;
}
if ($error === FALSE) {
$to = '';
$name = $_POST['name'];
$email_subject = $_POST['email_subject'];
$message = $_POST['message'];
$from = '';
$email_body = <<<MSG
You have received a new message from $name
Here is the message:
Name: $name
Email:$email
Subject: $email_subject
Message: $message
Body: $email_body
MSG;
mail($to, $email_subject, $email_body);
echo '<p>Your message has been sent correctly.</p>';
}
} else {
echo "<p>You have introducted an invalid code. Please <a href=\\"$lastpage\\">click here and try again</a></p>";
}
?>
<div id="sidebar">
<br /><br /><br /><br /><br />
<div class="block" id="fyi">
<h3 class="head">Header</h3>
<div class="block-content">
<form method="POST" name="contact_form" action="sidees.php">
Name: <input type="text" name="name"><br>
Subject: <input name="email_subject" type="text"><br>
Email: <input type="text" name="email"><br>
Message: <textarea name="message" style="width: 144px">
</textarea><br>
<img src="captcha_code_file.php" /><br>
Enter your code here<input id="6_letters_code" name="6_letters_code" type="text" ><br>
<input type="submit" value="Enviar"><br>
</form>
</div>
</div>