Jump to content

Recommended Posts

Hello. I am trying to make a form work on a website. The problem i am having is redirection after the form sends. Right now I just get a white screen and the email sends. To view it online please visit: http://staging.volumeforlife.com/contact.html

 

Here is the PHP:

<?php

//**********************************************************
//						           *
//	volumeforlife.com				   *
//	PHP mailer script created by versionthree	   *
//						           *
//**********************************************************

if(isset($_POST['submit'])) {

// basic mail variables
$to = "jon@versionthree.ca"; //for multiple email addresses separate addresses with a comma
$subject = "Website Comment";
$from = "This has just been sent from www.volumeforlife.com";

// Retrieve form post
$name_field = $_POST['thename'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$comment = $_POST['comment'];

// Collect date
$date = date("D M d, Y H:i:s");

// The message body
$message = "$date\n\nName: $thename\nPhone: $phone\nEmail: $email\n\nComment: $comment\n  ";

// Redirect pages
$success = 'http://staging.volumeforlife.com/contact_success.html';  // sets the page if the form is completed successfully
$deny = 'http://staging.volumeforlife.com/contact_deny.html';  // sets the page if the form has an error

// Send the message
$ok = mail($to, $subject, $message, $from);  

// Redirects the User after submission
if ($ok) {
include("$success");
} else {
include("$deny");
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/74111-mail-help/
Share on other sites

that is entirely wrong!

 

Change the Above to this:

<?php

if ($_POST['submit']=="true") { 
mail($to, $subject, $message, $from); 
header("Location: http://staging.volumeforlife.com/contact_success.html");


}else{ header("Location: http://staging.volumeforlife.com/contact_deny.html");} ?>

Link to comment
https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374187
Share on other sites

i agree wests version will throw errors use mine

<?php

if ($_POST['submit']=="true") { 
mail($to, $subject, $message, $from); 
header("Location: http://staging.volumeforlife.com/contact_success.html");


}else{ header("Location: http://staging.volumeforlife.com/contact_deny.html");} ?>

Link to comment
https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374203
Share on other sites

Wow, that was quick. Thanks for the help guys. As you can probably tell, i am very new to PHP. I just picked up some basics, primarily I work in Flash and Design.

 

This help is much appreciated!

 

This is what I have now, is it right? Or are there other errors?

<?php

//**********************************************************
//						           *
//	volumeforlife.com				   *
//	PHP mailer script created by versionthree	   *
//						           *
//**********************************************************

if(isset($_POST['submit'])) {

// basic mail variables
$to = "jon@versionthree.ca"; //for multiple email addresses separate addresses with a comma
$subject = "Website Comment";
$from = "This has just been sent from www.volumeforlife.com";

// other details
$name_field = $_POST['thename'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$comment = $_POST['comment'];
$date = date("D M d, Y H:i:s");
$message = "$date\n\nName: $thename\nPhone: $phone\nEmail: $email\n\nComment: $comment\n  ";


// Sends email and redirects
if ($_POST['submit']=="true") { 
mail($to, $subject, $message, $from); 
header("Location: http://staging.volumeforlife.com/contact_success.html");


}else{ header("Location: http://staging.volumeforlife.com/contact_deny.html");
}
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374205
Share on other sites

It's ugly, do this.

<?php

//**********************************************************
//						           *
//	volumeforlife.com				   *
//	PHP mailer script created by versionthree	   *
//						           *
//**********************************************************

if(isset($_POST['submit'])) {

// basic mail variables
$to = "jon@versionthree.ca"; //for multiple email addresses separate addresses with a comma
$subject = "Website Comment";
$from = "This has just been sent from www.volumeforlife.com";

// other details
$name_field = $_POST['thename'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$comment = $_POST['comment'];
$date = date("D M d, Y H:i:s");
$message = "$date\n\nName: $thename\nPhone: $phone\nEmail: $email\n\nComment: $comment\n  ";


// Sends email and redirects
 if ($_POST['submit']=="true") { 
    mail($to, $subject, $message, $from); 
    header("Location: http://staging.volumeforlife.com/contact_success.html");
 }else{ 
    header("Location: http://staging.volumeforlife.com/contact_deny.html");
 }
}
?>
There was also a misaligned bracket.

Link to comment
https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374212
Share on other sites

<?php

if($_POST['submit']=="true") { 

mail($to, $subject, $message, $from); 
header("Location: http://staging.volumeforlife.com/contact_success.html");
}



elseif ($_POST['submit']=="false") { 
header("Location: http://staging.volumeforlife.com/contact_deny.html");}
}?>

Link to comment
https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374234
Share on other sites

<body>
<div id="center">
	<div id="header05">
		<a id="logo" href="index.html"></a>
		<a id="nav1" href="about.html"></a>
		<a id="nav2" href="products.html"></a>
		<a id="nav3" href="services.html"></a>
		<a id="nav4" href="gallery.html"></a>
		<div id="nav5-current"></div>
	</div>
	<div id="contactImage"></div>
  		<div id="contactContent">
        	<a href="http://maps.google.ca/maps?f=l&hl=en&geocode=&q=volume&near=edmonton&ie=UTF8&ll=53.454046,-113.505979&spn=0.015461,0.043602&z=15&iwloc=A&om=1" target="_blank" title="View Map On Mapquest"><img src="i/b_blank.gif" alt="View Map on Mapquest" width="313" height="116" /></a>
            
            <form method="POST" action="c/sendEmail.php">
                <input type="text" id="thename" name="thename" size="40" value="" class="input-box" /><br />
                <input type="text" id="phone" name="phone" size="40" value="" class="input-box" /><br />
                <input type="text" id="email" name="email" size="40" value="" class="input-box" /><br />
                <textarea type="text" id="comment" name="comment" rows="8" cols="40" value="" class="input-box"></textarea><br />
                <input type="reset" value="Reset" name="reset" class="reset-box" width="71" /> <input type="submit" value="Send" name="submit" class="submit-box" width="71" />
            </form>
      </div>
        
	<div id="footer">
		© <script type="text/javascript">renderYear();</script> Volume Hair and Body Maintenance   |   Site by <a class="versionthree" href="http://www.versionthree.ca" target="_blank">versionthree</a>		</div>
</div>
</body>

 

<?php

//**********************************************************
//						           *
//	volumeforlife.com				   *
//	PHP mailer script created by versionthree	   *
//						           *
//**********************************************************

if(isset($_POST['submit'])) {

// basic mail variables
$to = "jon@versionthree.ca"; //for multiple email addresses separate addresses with a comma
$subject = "Website Comment";
$from = "This has just been sent from www.volumeforlife.com";

// other details
$name_field = $_POST['thename'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$comment = $_POST['comment'];
$date = date("D M d, Y H:i:s");
$message = "$date\n\nName: $thename\nPhone: $phone\nEmail: $email\n\nComment: $comment\n  ";


// Sends email and redirects
  if ($_POST['submit']=="true") { 
     mail($to, $subject, $message, $from); 
     header("Location: http://staging.volumeforlife.com/contact_success.html");
  }elseif ($_POST['submit']=="false") { 
header("Location: http://staging.volumeforlife.com/contact_deny.html");}
  }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374266
Share on other sites

<?php

//**********************************************************
//						           *
//	volumeforlife.com				   *
//	PHP mailer script created by versionthree	   *
//						           *
//**********************************************************

if(isset($_POST['submit'])) {

// basic mail variables
$to = "jon@versionthree.ca"; //for multiple email addresses separate addresses with a comma
$subject = "Website Comment";
$from = "This has just been sent from www.volumeforlife.com";

// other details
$name_field = $_POST['thename'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$comment = $_POST['comment'];
$date = date("D M d, Y H:i:s");
$message = "$date\n\nName: $thename\nPhone: $phone\nEmail: $email\n\nComment: $comment\n  ";

// Sends email and redirects
 if ($_POST['submit']=="send") { 
    mail($to, $subject, $message, $from); 
    header("Location: http://staging.volumeforlife.com/contact_success.html");
 }else { 
header("Location: http://staging.volumeforlife.com/contact_deny.html");}
 }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374272
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.