Form not redirecting
Moderator: General Moderators
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
To be honest I'm not entirely sure, as I took the majority of this code from a book. I have just been trying to tweak it for my own needs. I think it has something to do with Session ID, but I can't find anything in the functions which point to it.
Regardless of this, it is not causing the problem, as I have tried removing it and the page still just refreshes. It must be something very fundamental but also very simple I'm sure, I just can't work it out?
Regardless of this, it is not causing the problem, as I have tried removing it and the page still just refreshes. It must be something very fundamental but also very simple I'm sure, I just can't work it out?
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
whats your error_reporting set to?
try adding this at the VERY beggining of the script. BEFORE any includes, the very first line.
let us know what happens
try adding this at the VERY beggining of the script. BEFORE any includes, the very first line.
Code: Select all
<?php
error_reporting(E_ALL);
?>OK, some errors!
Notice: Undefined variable: link in C:\phpWeb\Right-Track\includes\dbconn.inc on line 2
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\phpWeb\Right-Track\includes\dbconn.inc:2) in C:\phpWeb\Right-Track\includes\funclib.inc on line 3
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\phpWeb\Right-Track\includes\dbconn.inc:2) in C:\phpWeb\Right-Track\includes\funclib.inc on line 3
Warning: Cannot modify header information - headers already sent by (output started at C:\phpWeb\Right-Track\includes\dbconn.inc:2) in C:\phpWeb\Right-Track\includes\funclib.inc on line 4
Just so you can see, my 2 include files:
funclib.inc
dbconn.inc
Not sure what all this means. I've probably messed up big time, but any advice appreciated.
Thanks.
?>
Notice: Undefined variable: link in C:\phpWeb\Right-Track\includes\dbconn.inc on line 2
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\phpWeb\Right-Track\includes\dbconn.inc:2) in C:\phpWeb\Right-Track\includes\funclib.inc on line 3
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\phpWeb\Right-Track\includes\dbconn.inc:2) in C:\phpWeb\Right-Track\includes\funclib.inc on line 3
Warning: Cannot modify header information - headers already sent by (output started at C:\phpWeb\Right-Track\includes\dbconn.inc:2) in C:\phpWeb\Right-Track\includes\funclib.inc on line 4
Just so you can see, my 2 include files:
funclib.inc
Code: Select all
<?php
session_start();
header('Cache-Control: public');
function cleanMemberSession($id, $login, $pass)
{
$_SESSION[id] = $id;
$_SESSION[login] = $login;
$_SESSION[password] = $pass;
$_SESSION[logged_in] = true;
}
?>Code: Select all
<?php
$link;
connectToDB();
function connectToDB()
{
global $link;
$link = mysql_connect("localhost","root","quiksilver");
if(!$link)
die("Could not connect to MySQL");
mysql_select_db("righttrack", $link);
}
function newUser($login, $pass)
{
global $link;
$result=mysql_query("insert into user_details (username, password)
values('$login', '$pass')", $link);
return mysql_insert_id($link);
}
function getRow($table, $fnm, $fval)
{
global $link;
$result=mysql_query("select * from $table where $fnm='$fval'", $link);
if(!$result)
die("getRow fatal error: " .mysql_error());
return mysql_fetch_array($result);
}
?>Thanks.
?>
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
This why I prefer JS or meta refreshes to Header...
Warning: Cannot modify header information - headers already sent by (output started at C:\phpWeb\Right-Track\includes\dbconn.inc:2) in C:\phpWeb\Right-Track\includes\funclib.inc on line 4
If output has already started - you cannot use Header(). Headers are sent prior to the body of the page - which means even a single character outputted will block any headers sent afterwards.
JS on the other hand is unaffected by this. I'd suggest at least testing it as per my prior suggestion in place of the header...
I also see now why SID is being sent by url - can't set a cookie after something is outputted either...
Warning: Cannot modify header information - headers already sent by (output started at C:\phpWeb\Right-Track\includes\dbconn.inc:2) in C:\phpWeb\Right-Track\includes\funclib.inc on line 4
If output has already started - you cannot use Header(). Headers are sent prior to the body of the page - which means even a single character outputted will block any headers sent afterwards.
JS on the other hand is unaffected by this. I'd suggest at least testing it as per my prior suggestion in place of the header...
I also see now why SID is being sent by url - can't set a cookie after something is outputted either...
Ok, so I now put in ob_start(); before my includes and the header errors have gone away. The 2 undefined variables link, and login are still there.
If I add in the correct details and submit again, I get the following errors:
Notice: Undefined variable: link in C:\phpWeb\Right-Track\includes\dbconn.inc on line 2
Notice: Undefined variable: message in C:\phpWeb\Right-Track\auth.php on line 29
Notice: Use of undefined constant id - assumed 'id' in C:\phpWeb\Right-Track\includes\funclib.inc on line 7
Notice: Use of undefined constant login - assumed 'login' in C:\phpWeb\Right-Track\includes\funclib.inc on line 8
Notice: Use of undefined constant password - assumed 'password' in C:\phpWeb\Right-Track\includes\funclib.inc on line 9
Notice: Use of undefined constant logged_in - assumed 'logged_in' in C:\phpWeb\Right-Track\includes\funclib.inc on line 10
Notice: Undefined index: button in C:\phpWeb\Right-Track\auth.php on line 33
Notice: Undefined index: button in C:\phpWeb\Right-Track\auth.php on line 38
Notice: Undefined index: button in C:\phpWeb\Right-Track\auth.php on line 43
Notice: Undefined index: button in C:\phpWeb\Right-Track\auth.php on line 48
Notice: Undefined index: button in C:\phpWeb\Right-Track\auth.php on line 53
Notice: Undefined index: button in C:\phpWeb\Right-Track\auth.php on line 58
This obviously shows that something is wrong with the button varibale.
I have changed the headers to the JS as suggested aswell.
If I add in the correct details and submit again, I get the following errors:
Notice: Undefined variable: link in C:\phpWeb\Right-Track\includes\dbconn.inc on line 2
Notice: Undefined variable: message in C:\phpWeb\Right-Track\auth.php on line 29
Notice: Use of undefined constant id - assumed 'id' in C:\phpWeb\Right-Track\includes\funclib.inc on line 7
Notice: Use of undefined constant login - assumed 'login' in C:\phpWeb\Right-Track\includes\funclib.inc on line 8
Notice: Use of undefined constant password - assumed 'password' in C:\phpWeb\Right-Track\includes\funclib.inc on line 9
Notice: Use of undefined constant logged_in - assumed 'logged_in' in C:\phpWeb\Right-Track\includes\funclib.inc on line 10
Notice: Undefined index: button in C:\phpWeb\Right-Track\auth.php on line 33
Notice: Undefined index: button in C:\phpWeb\Right-Track\auth.php on line 38
Notice: Undefined index: button in C:\phpWeb\Right-Track\auth.php on line 43
Notice: Undefined index: button in C:\phpWeb\Right-Track\auth.php on line 48
Notice: Undefined index: button in C:\phpWeb\Right-Track\auth.php on line 53
Notice: Undefined index: button in C:\phpWeb\Right-Track\auth.php on line 58
This obviously shows that something is wrong with the button varibale.
I have changed the headers to the JS as suggested aswell.