Jump to content


Photo

Trying to forward to comfirmation page after message sent?


  • Please log in to reply
3 replies to this topic

#1 john510

john510
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 05 July 2006 - 04:15 PM

Im trying to have my page go to another URL after my form has been sent but dont understand what Im doing wrong!
I can get the alert message after the completion of the form but not the forward to the new html page.

Here is the top of my script where Im haing a problem:

<?
session_start();
include_once("admin/inc.php");
include_once("header_inc.php");
if ($_POST['action'] == "go") {
 session_save_path("/home/users/web/b620/pow.mysite/classifieds/");
  $name = $_POST['name'];
  $email = $_POST['email'];
  $content = $_POST['content'];
  $IP = $_SERVER['REMOTE_ADDR'];
  if (!preg_match("(^[-\w\.]+@([-a-z0-9]+\.)+[a-z]{2,4}$)i", $email)) $alert = "You have entered an invalid email address.";
  if ($name == "" OR $email == "" OR $content == "") $alert = "To send a message, please complete all 3 fields.";
  if ($_SESSION['mail_count'] >= "3") $alert = "Only 3 messages can be sent per session.";
  if (!$alert) {
    if (!isset($_SESSION['mail_count'])) $_SESSION['mail_count'] = 0;
    $_SESSION['mail_count']++;
    $message .= "Name as follows:\n\n";
    $message .= "$name\n\n";
    $message .= "Email address as follows:\n\n";
    $message .= "$email\n\n";
    $message .= "Message as follows:\n\n";
    $message .= "$content\n\n";
    $message .= "IP address is: $IP\n\n";
    mail("john@mysite.com", "Mysite.com Message" , "$message", "From: Mysite Message Center <>");
    $name = "";
    $email = "";
    $content = "";
    $alert = "Your message has been sent.";
header("Location: commentsent.htm");
  }
}
?>

It should forward  to the "commentsent.htm" page after the form is successfully sent.

#2 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 05 July 2006 - 04:23 PM

I am not sure if your include_once("header_inc.php"); print out anything or not. But header function must not have any output before it (no html, alert, text).

NoGray.com


#3 SharkBait

SharkBait
  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 05 July 2006 - 04:28 PM

Yes before executing a header() you must not have any screen output.

I also put exit() after a header so that if there is anything else in the script, I dont want it buggering up :)



#4 john510

john510
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 05 July 2006 - 04:53 PM

no, I tried these , this does not forward to the commentsent.htm page....

?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users