Jump to content

[SOLVED] Redirecting to a new web page


dryan11

Recommended Posts

I've done many different searches looking for an answer to my issue. Everything is working fine except the redirect. From what I've read it should work fine, but it never redirects. Here is my code:

 

 <?php
// Variables
	$from = $_REQUEST['FieldData0'];
$email = $_REQUEST['FieldData1'];
$phone = $_REQUEST['FieldData2'];
$company = $_REQUEST['FieldData3'];

// User information
	$content = "Name: $from\r\n";
$content = "$content Email Address: $email\r\n";
    $content = "$content Phone Number: $phone\r\n";
    $content = "$content Company: $company\r\n";

// Wrap content to abide by php rules  
$content = wordwrap($content, 70);

// Send email
mail('myemail@hotmail.com', 'Someone Sent You Something!!!', $content);

// Redirect user to thank you page ************ NOT WORKING ************
header('Location: http://www.yahoo.com');
?>

Link to comment
Share on other sites

Add the following two lines of code immediately after your first opening <?php tag -

 

ini_set("display_errors", "1");
error_reporting(E_ALL);

 

Thanks for your quick response!

 

After adding those two lines, I received this error in the web browser.

 

Warning: Cannot modify header information - headers already sent by (output started at /hermes/web10/b871/moo.mytriptical/Test/newmail.php:1) in /hermes/web10/b871/moo.mytriptical/Test/newmail.php on line 23

 

Any further assistance would be greatly appreciated.

Link to comment
Share on other sites

output started at newmail.php:1 (line 1)

 

You have something before the <?php tag. It is either actual character(s) in the file or the file has been saved as UTF-8 encoding and the BOM (Byte Order Mark) characters that the editor puts at the start of the file is the output being sent.

 

Check there is nothing before the <?php tag in the file and either save the file as ANSI (ASCII) or if you must save it as UTF-8, save it without the BOM.

Link to comment
Share on other sites

all redirection must be genuine... that means NO spaces, text, or anything before the actual code.

 

ex.

<html>

<?php

//your code here

header("location: blajh.com");

?>

 

this will not work because there is text before the redirection!

Link to comment
Share on other sites

output started at newmail.php:1 (line 1)

 

You have something before the <?php tag. It is either actual character(s) in the file or the file has been saved as UTF-8 encoding and the BOM (Byte Order Mark) characters that the editor puts at the start of the file is the output being sent.

 

Check there is nothing before the <?php tag in the file and either save the file as ANSI (ASCII) or if you must save it as UTF-8, save it without the BOM.

 

Thanks!

 

I'm not sure exactly what was causing the issue, but after I read this I rewrote the file just using Notepad and it worked fine. I was using Dreamweaver, so I'm assuming that is saves the file with some extra characters that I didn't want.

 

Thanks again for the help. Was very simple, wish I was able to figure that one out on my own.

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.