Basically I’ve a Contact Form where a user fills in Name, Email Address and Comments and then there is a Submit button. If I just hit “Submit” without filling in anything or wrong information, it takes me to this page, send_form_email.php. This page has all the validators in it. I want it to sort of (I say sort of because I still need to check whether they input everything correctly) bypass this page and go to “submitted-contact.php” page (it’s going to this page but its not showing the following as specified in the 2) where it displays one of the 2 things: 1) Login Success 2) Try Again!
Right now, there’s nothing showing.
send_form_email.php has this at the very top and it calls header location to the page,
submitted-contact.php
[php]
'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.
'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.
'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); $sendit= @mail($email_to, $email_subject, $email_message, $headers); if($sendit){ header('Location:submitted-contact.php'); }else{echo "Email failed to send";} } ?>
[/php]
submitted-contact.php
[php]
<div class="navigation">
<div class="container">
<a href="#"><img src="images/logo.png"</a>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About Us</a></li>
<li><a href="/service">Services</a></li>
<li><a href="/blog">Blog</a></li>
<li><a href="/index.html#contact">Contact</a></li>
</ul>
</div>
</div>
<div id="submitted-content-2">
<div class="content container">
<?php
if (!isset($_SESSION['flunk'])){
$myString = "MESSAGE FLUNKED!";
echo $myString;
}else (!isset($_SESSION['pass'])){
$myString2 = "MESSAGE PASSED!";
?>
<div class="clear"></div>
</div>
</div>
</div>
The php code in submitted-contact.php, the following code is in the right location but just the wrong syntax?
Basically, I want to commute from send_form_email.php to submitted-contact.php one of the two things:
- If user inputted everything well on the Contact Page, show them, “You’re logged in”
- If user inputted wrong information or did not fill in everything on the Contact Page, show them, “Try Again”
I want that to be shown withing my Sorry, I know this was a long post but I really could use a hand on this. I have been trying to figure this out for the past couple of days! Thanks guys
D3158