Jump to content

header not redirecting


droidus

Recommended Posts

why won't this header redirect?  it doesn't seem to like the mysql_close.  can i update the database before redirecting to another page?  is it possible?

 

<?php
session_start();
$name = "uname";
$lastLogin = date('l jS \of F Y h:i:s A');
require_once('../Connections/uploader.php');
mysql_select_db($database_uploader, $uploader); 
$query = "SELECT * FROM members WHERE uname='"
. $name . "'";
$result = mysql_query($query) or die(mysql_error());
// connect to database here
					MYSQL_CONNECT($server, $user, $password) or die ("Server unreachable");
					MYSQL_SELECT_DB($database) or die ("Database non existent");
					if (mysql_num_rows($result) > 0) { 
	$row = mysql_fetch_array($result) or die(mysql_error());
	mysql_query("UPDATE members
					SET lastLogin='$lastLogin'
					WHERE uname='$name'")
					// ERROR MESSAGE??
					or die(mysql_error());  
					mysql_close($con);
					header('Location: redirect.php');
					}

?>

 

thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/245558-header-not-redirecting/
Share on other sites

you're missing a semi-colon after:

mysql_query("UPDATE members SET lastLogin='$lastLogin' WHERE uname='$name'")

 

also, in this line:

mysql_close($con);

 

where does $con come from? you seem to be connecting to mysql without storing the resource in a variable (unless it's in uploader.php)...

you're probably getting a warning about that, but you can surpress it with the @ sign (if you just want a quick fix to test things):

@mysql_close();

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.