<form id="contactform" method="post" action="submitemail.php" > <fieldset> <label for="name">Name</label> <input type="text" name="name" id="name" onfocus="if(this.value=='Name')this.value='';" onblur="if(this.value=='')this.value='Name';" value="Name" /> <label for="subject">Subject</label> <input type="text" name="subject" id="subject" onfocus="if(this.value=='Subject')this.value='';" onblur="if(this.value=='')this.value='Subject';" value="Subject" /> <label for="email">Email Address</label> <input type="text" name="email" id="email" onfocus="if(this.value=='Email Address')this.value='';" onblur="if(this.value=='')this.value='Email Address';" value="Email Address" /> <input type="submit" name="submit" id="submit" align="right" value="Submit" /> </fieldset> <fieldset> <label for="question"></label> <textarea id="question" name="question" rows="5" value="Message" cols="20" onfocus="if(this.value=='Message')this.value='';" onblur="if(this.value=='')this.value='Message';">Message</textarea> </fieldset> </form>
And the PHP functioning perfectly:
<?php
redirect( 'Location: http://rickbrossgraphics.com/Danny/index.php' );
?>
<?php
/************************
* Variables you can change
*************************/
$mailto = "zxcvzxcvzxcv@hotmail.com"; // Enter your mail addres here.
$cc = "";
$bcc = "";
$subject = "From Your Website"; // Enter the subject here.
$vname = ucwords($_POST['name']); // Displays entered name in the "From" field of the e-mail.
// Replace with "Website contact form" etc (with quotes!) if
// you don't want to display the name.
/************************
* do not modify anything below unless you know PHP/HTML/XHTML
*************************/
$email = $_POST['email'];
function validateEmail($email)
{
if(eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}(\.[a-zA-Z]{2,3})?(\.[a-zA-Z]{2,3})?$', $email))
return true;
else
return false;
}
if((strlen($_POST['name']) < 1 ) || (strlen($email) < 1 ) || (strlen($_POST['question']) < 1 ) || validateEmail($email) == FALSE){
$emailerror .= '';
if(strlen($_POST['name']) < 1 ){
$emailerror .= '<span class="wrong">Please enter your name.</span>';
}
if(strlen($email) < 1 ){
$emailerror .= '<span class="wrong">Please enter your e-mail address.</span>';
}
if(validateEmail($email) == FALSE) {
$emailerror .= '<span class="wrong">Please enter a valid e-mail address.</span>';
}
if(strlen($_POST['question']) < 1 ){
$emailerror .= '<span class="wrong">Please enter your message.</span>';
}
} else {
$emailerror .= "<span>Your message has been sent successfully. Thank you!</span>";
// NOW SEND THE ENQUIRY
$timestamp = date("F j, Y, g:ia");
$messageproper ="\n\n" .
"Name: " .
ucwords($_POST['name']) .
"\n" .
"Email: " .
$email .
"\n" .
"Subject: " .
$_POST['subject'] .
"\n" .
"Comments: " .
"\n" .
$_POST['question'] .
"\n" .
"\n\n";
$messageproper = trim(stripslashes($messageproper));
mail($mailto, $subject, $messageproper, "From: \"$vname\" <".$_POST['email'].">\nReply-To: \"".ucwords($_POST['first_name'])."\" <".$_POST['email'].">\nX-Mailer: PHP/" . phpversion() );
}
?>
<?php echo $emailerror; // Displays the error/success message. ?>
I just need to send the user back to index.php after the Email is sent.
Im guessing the
<?php redirect( 'Location: http://rickbrossgraphics.com/Danny/index.php' ); ?>
isn't appropriate or i need to do something in the "else" section by the email error thing...
This post has been edited by TechSupport: 28 December 2009 - 10:11 PM

New Topic/Question
Reply




MultiQuote




|