skis Posted October 24, 2006 Share Posted October 24, 2006 I wrote this code and tested it using a local apache install with php5 installed as a module, and I am now trying to use it on my web host's server which uses apache with php4 installed as cgi. On my local server, this code works perfectly fine. When I try it on my webhost's server, it will return "header didnt work" (one of my or die() strings). Does this have something to do with the versions of php or having php running as cgi instead of as an apache module?CODE:correct username and password returns "header didnt work"i only added the or die()'s for debugging. <html><body bgcolor=#96DCFF><?php//check if login is correctrequire('connect.php');$db_name = "CENSORED";$tbl_name = "credentials";$myusername = $_POST['myusername']; $mypassword = $_POST['mypassword']; $sql = "SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";$checkadminsql = "SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword' and admin='1'";$adminresult = mysql_query($checkadminsql);$result = mysql_query($sql);$count = mysql_num_rows($result);$admincount = mysql_num_rows($adminresult);if ($count == 1 && $admincount == 1) { $isadmin = "1"; session_register("myusername") or die('session register myusername didnt work'); session_register("mypassword") or die('session register mypassword didnt work'); session_register("isadmin") or die('session register isadmin didnt work'); header("location:queue.php") or die('header didnt work');}elseif ($count == 1) { session_register("myusername"); session_register("mypassword"); header("location:form.php"); } else { echo "Wrong Username or Password"; echo "<br><br><a href=\"login.php\">Try Again</a>";}?></body></html> Link to comment Share on other sites More sharing options...
Caesar Posted October 24, 2006 Share Posted October 24, 2006 Can you please post the exact error you get? I don't think I've seen the "Header didn't work" error yet. :-) Link to comment Share on other sites More sharing options...
skis Posted October 24, 2006 Author Share Posted October 24, 2006 the exact error is "header didnt work", which is coming from:if ($count == 1 && $admincount == 1) { $isadmin = "1"; session_register("myusername") or die('session register myusername didnt work'); session_register("mypassword") or die('session register mypassword didnt work'); session_register("isadmin") or die('session register isadmin didnt work'); [b]header("location:queue.php") or die('header didnt work');[/b]}I have tried using an absolute path instead of a relative path for header() and it does the same thing. Link to comment Share on other sites More sharing options...
Caesar Posted October 24, 2006 Share Posted October 24, 2006 This is probably me being lazy but...just to rule out the possibility of the header() function not working...try a simple test on a clean php page....[code]<?php $time = time(); if($time != '') { header("Location: http://google.com"); }?>[/code]If that works...then there is likely an error in syntax or logic, in your code. Link to comment Share on other sites More sharing options...
skis Posted October 24, 2006 Author Share Posted October 24, 2006 That does work both locally and on the web host. I will continue going over my code to try and figure out why this isn't working. Link to comment Share on other sites More sharing options...
skis Posted October 24, 2006 Author Share Posted October 24, 2006 I cannot find what is wrong here, can someone please help me proofreading my code? Link to comment Share on other sites More sharing options...
skis Posted October 24, 2006 Author Share Posted October 24, 2006 Nevermind, I got it now. It was because I was sending <html> before the header. Guess I should read stickies... Link to comment Share on other sites More sharing options...
Recommended Posts