|
|
#1 (permalink) |
|
Registered User
Comfy Contributor
Joined in Mar 2006
Lives in UT
Hosted on SH92
165 posts
Gave thanks: 28
Thanked 0 times
|
Yesterday this worked and now it doesn't and I can't figure out why. Everytime I try to log in it just comes back to the login screen. I've checked and rechecked all of my mysql db information and still nothing and like I said, it worked yesterday, and this morning, and I haven't touched it since and I can't get it to work now (or at least login) Any help would be appreciated:
home.php <? include("inc/connect.php"); include("inc/auth.php"); include("inc/nav.php"); ?> <title> Testing </title> <head> </head> <body> <center> You are now logged in. </center> </body> connect.php <? // Login & Session example by sde // connect.php // replace with your db info $hostname="localhost"; $mysql_login="anderse_cpusers"; $mysql_password="********"; $database="anderse_users"; if (!($db = mysql_connect($hostname, $mysql_login , $mysql_password))){ echo "Error: " . mysql_error(); }else{ if (!(mysql_select_db("$database",$db))) { echo "Error: " . mysql_error(); } } ?> auth.php <html> <head> <title>Login</title> </head> <? // Login & Session example by sde // auth.php // start session session_start(); $_SESSION['time'] = time(); // convert username and password from _POST or _SESSION if($_POST){ $_SESSION['username']=$_POST["username"]; $_SESSION['password']=$_POST["password"]; } // query for a user/pass match $result=mysql_query("select * from users where username='" . $_SESSION['username'] . "' and password='" . $_SESSION['password'] . "'"); // retrieve number of rows resulted $num=mysql_num_rows($result); // print login form and exit if failed. if($num < 1){ echo "<br><br><br><br><br><center><b>Please login:</b><br><br> <form method=POST action=home.php> Username: <input type=text name=\"username\"><br> Password: <input type=password name=\"password\"><br><br> <input type=submit value=Login> </center></form> <p></p> <br> <p></p> <br> <p></p> <br> <p></p> <br> <p></p> <center> All Rights Reserved - 2006 ®</center>"; exit; } ?> </html> nav.php <head> <META http-equiv="REFRESH" content="60"; url="nav.php"> </head> <? $rnq=("SELECT rank,lastname,password FROM users WHERE username='" . $_SESSION['username']."'"); $rs=mysql_query($rnq); while( $row = mysql_fetch_array($rs)) { echo("<table align='right' width='200'><tr>"); echo("<font color=green>"); echo("Logged In:  </font><font color=yellow>".$row["rank"]); echo(" ".$row["lastname"]); echo("</tr></font>"); } ?> <? $ztime = date("dHi M y", strtotime("now + 5 hour")); $time = date("dHi M y"); ?> <tr> <? echo "<font color=green>Local Time: </font>",$time;?> </tr> <tr> <? echo "<font color=green>Zulu Time:   </font>",$ztime;?> </tr> </table> <style> <!-- .skin0{ position:absolute; width:165px; border:1px solid red; background-color:menu; font-family:Verdana; line-height:20px; cursor:default; font-size:14px; z-index:100; visibility:hidden; } .menuitems{ padding-left:10px; padding-right:10px; } --> </style> </head> <body bgcolor="#000000" text="#FF0000" link="#0000FF" vlink="#0000FF" alink="#0000FF"> <div id="ie5menu" class="skin0" onMouseover="highlightie5(event)" onMouseout="lowlightie5(event)" onClick="jumptoie5(event)" display:none> <div class="menuitems" url="home.php">Home</div> <div class="menuitems" url="log.php">Log</div> <div class="menuitems" url="keyper.php">Key Personnel</div> <div class="menuitems" url="options.php">Edit Personal Info</div> <div class="menuitems" url="admin.php">Admin Area</div> <div class="menuitems" url="logout.php">Logout</div> </div> <script language="JavaScript1.2"> var display_url=0 var ie5=document.all&&document.getElementById var ns6=document.getElementById&&!document.all if (ie5||ns6) var menuobj=document.getElementById("ie5menu") function showmenuie5(e){ var rightedge=ie5? document.body.clientWidth-event.clientX : window.innerWidth-e.clientX var bottomedge=ie5? document.body.clientHeight-event.clientY : window.innerHeight-e.clientY if (rightedge<menuobj.offsetWidth) menuobj.style.left=ie5? document.body.scrollLeft+event.clientX-menuobj.offsetWidth : window.pageXOffset+e.clientX-menuobj.offsetWidth else menuobj.style.left=ie5? document.body.scrollLeft+event.clientX : window.pageXOffset+e.clientX if (bottomedge<menuobj.offsetHeight) menuobj.style.top=ie5? document.body.scrollTop+event.clientY-menuobj.offsetHeight : window.pageYOffset+e.clientY-menuobj.offsetHeight else menuobj.style.top=ie5? document.body.scrollTop+event.clientY : window.pageYOffset+e.clientY menuobj.style.visibility="visible" return false } function hidemenuie5(e){ menuobj.style.visibility="hidden" } function highlightie5(e){ var firingobj=ie5? event.srcElement : e.target if (firingobj.className=="menuitems"||ns6&&firingobj. parentNode.className=="menuitems"){ if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode //up one node firingobj.style.backgroundColor="highlight" firingobj.style.color="yellow" if (display_url==1) window.status=event.srcElement.url } } function lowlightie5(e){ var firingobj=ie5? event.srcElement : e.target if (firingobj.className=="menuitems"||ns6&&firingobj. parentNode.className=="menuitems"){ if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode //up one node firingobj.style.backgroundColor="black" firingobj.style.color="red" window.status='' } } function jumptoie5(e){ var firingobj=ie5? event.srcElement : e.target if (firingobj.className=="menuitems"||ns6&&firingobj. parentNode.className=="menuitems"){ if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode if (firingobj.getAttribute("target")) window.open(firingobj.getAttribute("url"),firingob j.getAttribute("target")) else window.location=firingobj.getAttribute("url") } } if (ie5||ns6){ menuobj.style.display='' document.oncontextmenu=showmenuie5 document.onclick=hidemenuie5 } </script>
__________________
~CJA~ 72.29.87.117 "Constantly lost in the world of PHP" is my personal understatement. |
|
|
|
|
|
#2 (permalink) | |
|
Surpass Fan
Excelling Contributor
Joined in Nov 2005
Lives in Colorado
Hosted on DEDI
934 posts
Gave thanks: 2
Thanked 94 times
|
Quote:
Code:
<form method=\"POST\" action=\"home.php\"> Username: <input type=text name=\"username\"><br> Password: <input type=password name=\"password\"><br><br> <input type=\"submit\" value=\"Login\"> Code:
if ($_POST) {
print_r($_POST);
exit;
}
__________________
Where would you be if you were at the highest court in the land (US)? |
|
|
|
|
|
|
#3 (permalink) |
|
Registered User
Comfy Contributor
Joined in Mar 2006
Lives in UT
Hosted on SH92
165 posts
Gave thanks: 28
Thanked 0 times
|
Thanks Cowboy, I'll give that a shot.
Now, I am a little confused. I'm at my work computer and I can access the site just fine and everything works the way it is supposed to be. Could it be a browser issue? At work I'm using I.E. 6.0 and at home I use Firefox and I.E. 7.0 but neither of those worked. Maybe? Thanks again, CJ
__________________
~CJA~ 72.29.87.117 "Constantly lost in the world of PHP" is my personal understatement. |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Fresh Surpasser
Joined in Oct 2006
3 posts
Gave thanks: 1
Thanked 1 Time in 1 Post
|
An issue you may be having is you're calling session_start() after you've outputted some HTML to the browser. If you're using cookie based sessions (which I'm assuming you are), then the session_start call should be before anything is outputted to the browser. A good way of ensuring this is to make it the very first thing your PHP script does, i.e. removing the session_start call from auth.php and changing the first line of home .php from:
Code:
<? Code:
<? session_start(); |
|
|
|
| This user thanks lust_and_anger for this great post! | Kayla (October 26th, 2006) |