header() Function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
skky1142
Forum Newbie
Posts: 1
Joined: Wed Feb 02, 2005 12:22 am

header() Function

Post by skky1142 »

ok, i have a small script that when i am done adding the e-mail address to a database i want my page to redirect. This is the code i am using:

Code: Select all

<?php

include("db_connect.php");




$e_address=$_POST["email"];//<-- get's e-mail address from form
$date=date("d-m-Y");//<-- get's current date



list($userName, $mailDomain) = split("@", $e_address); //<-- [valide email] take a given email address and split it into the  username and domain. 
if (checkdnsrr($mailDomain, "MX")) 
	{ 
	  	if ( $userName == "" )
			{ 
				print ("The e-mail address is not valid.<br />");
			}
		else
			{
				add_email();
			}
	} 
else 
	{ 
	 	print ("The e-mail address is not valid.<br />");
	} 




function add_email()
{
//=======================
//Add the e-mail address to the database
//=======================
global $e_address;
global $date;

$query=("INSERT INTO `subscribers` ( `id` , `email_address` , `date_added` )
VALUES ( '', '$e_address', '$date' )");

$result = mysql_query($query) or die("Could not add your e-mail address to the database");
header("Location: confirm.php?m=1");




}


?>
This is what db_connect.php looks like:
(obviously the "x's" (xxxxxxxxxxxxxxx) is for censored information)

Code: Select all

<?
$link;
	connectToDB();
	function connectToDB()
		{
				global $link;
				
				$link = mysql_connect( "xxx.xxx.xxx.xx", "xxxxxxxx", "xxxxx" );
				
				if ( ! $link )
					die( "Couldn't Connect to MySQL" );
				mysql_select_db(" xxxxxxxxxxx", $link )
					or die ( "Couldn't open organizer: ".mysql_error() );
		}
?>

For some reason my script will not redirect. Am i going crazy? the code looks fine to me, if someone finds and error let me know, otherwise i have to notify the hosting company.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

have you tried placing full url's in the redirection? Have you checked your error logs, turned error reporting to E_ALL and set display errors to on?
Post Reply