Jump to content


the process form


2 replies to this topic

#1 AnTone Media

    Young Padawan

  • Members
  • Pip
  • 66 posts
  • Gender:Male
  • Location:Los Angeles
  • Interests:Knowledge:<br />Photoshop, Image Ready, Dreamweaver, After Effects, Maya, Final Cut Pro, Quark Xpress<br /><br />Barely Know (Want to know more):<br />Flash/Actionscript, Audition, Premiere

Posted 15 August 2006 - 08:42 PM

I have a form setup in PHP and was wondering how to get the process page to send me back to... well anypage on my site. here's the code I have.

<?php

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

$recipient = "antoniomartinez@an-tonemedia.com";
$subject   = "Site Submission";

$message   = "E-mail: $email \n";
$message  .= "URL: $url \n";
$message  .= "Comments: $comments \n\n";

$headers   = "From: My Form \n";
$headers  .= "Reply-To: $email";

mail($recipient,$subject,$message,$headers);
?>


#2 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 15 August 2006 - 08:57 PM

try this:

<?php
ob_start(); // output buffering as we modify headers later on

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

$recipient = "antoniomartinez@an-tonemedia.com";
$subject   = "Site Submission";

$message   = "E-mail: $email \n";
$message  .= "URL: $url \n";
$message  .= "Comments: $comments \n\n";

$headers   = "From: My Form \n";
$headers  .= "Reply-To: $email";

if( mail($recipient,$subject,$message,$headers) )
{
	  echo 'Message sent to: '. $recipient . ', redirecting...';
	  header("Refresh: 2; URL=page.php");
}
else
{
	  echo 'Error, message not sent.';
}

?>

by adding an if statement around the mail function, it allows you to both check if it sends, and as you wanted, redirect to a new page when sent.

Redirect line:
header("Refresh: 2; URL=page.php");

If you wanted it without the delay, use:
header("Location: url.php");

Hope thats what you need.

Matt.

#3 AnTone Media

    Young Padawan

  • Members
  • Pip
  • 66 posts
  • Gender:Male
  • Location:Los Angeles
  • Interests:Knowledge:<br />Photoshop, Image Ready, Dreamweaver, After Effects, Maya, Final Cut Pro, Quark Xpress<br /><br />Barely Know (Want to know more):<br />Flash/Actionscript, Audition, Premiere

Posted 16 August 2006 - 12:09 AM

SWEEEEEEEEEEEEEEEEEEEEEEEEEEEET it works





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users