Jump to content

Header("Location:") Problem


shaunrigby

Recommended Posts

Hi guys,

 

i am an amateur at PHP and I am building a website for a client, however i seem to have a problem with the header part of the script.

 

I have a simple form-mail script, and when the mail is sent the form relocates back to the home page, this is all fine and dandy, however the URL to the script processing page, still appears in the address bar; is this an IE7 fault? or is it actually PHP? is there a way around this?

 

Cheers Guys

Link to comment
Share on other sites

Yea, if you visit http://www.spacebarcomputers.com, and click on Contact us, fill random data into the form and press send, you will the be redirected to the index page, however the form processing page is still shown in the address bar. The script is below (note this is a BETA script)

 

<?php

//Polyglot feedback form processing
//(c) 2007 Shaun Rigby

@include_once 'includes/variables.php';

$formCheck = TRUE;
$reasonCount = 0;

$formFrom = $_POST['Name'];
$formSubject = $_POST['Subject'];
$formMessage = $_POST['message'];

if($formFrom == NULL){
	$formCheck = FALSE;
	$reasonCount++;
	$failureReason = "<li>You must give a name.</li>";
}

if($formSubject == NULL){
	$formCheck = FALSE;
	$reasonCount++;
	$failureReason = "<li>You must give a message subject.</li>";
}

if($formMessage == NULL){
	$formCheck = FALSE;
	$reasonCount++;
	$failureReason = "<li>You must type a message.</li>";
}

//------------------------------------------------------------------------------------------//

//If formCheck = true, send mail

if($formCheck = TRUE){

	//Compose Headers
	$headers = "From: Polyglot Website <$sendMailFrom>\r\n";
	$headers .= "To: $sendMailName <$sendMailTo>\r\n";
	$headers .= "Message-ID: <" . md5(date("GHs")) . "@" . $_SERVER['SERVER_NAME'] . ">\r\n";
	$headers .= "X-Priority: 3\r\n";
	$headers .= "X-Mailer: PHPMailer [version " . phpversion() . "]\r\n";
	$headers .= "MIME-Version: 1.0\r\n";
	$headers .= "Content-Type: text/plain\r\n";

	//Compose Subject
	$subject = "You have received a message from your website.";

	//Compose Message
	$message = "
Dear $sendMailName,

$formFrom, has send you a message with the subject, $formSubject, the message is below;

$formMessage";

	//Send Mail

	$mailStatus = mail($sendMailAddress,$subject,$message,$headers);

	if ($mailStatus = TRUE){
			header("Location:" . $websiteURL . "?pageid=9295");
	}
}

Link to comment
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.