Thread: MySQL/PHP Help
View Single Post
Old August 20th, 2006, 6:56 PM   #1 (permalink)
hunna03
Registered User
Comfy Contributor
 
hunna03's Avatar
 
Joined in Mar 2006
Lives in UT
Hosted on SH92
165 posts
Gave thanks: 28
Thanked 0 times
Exclamation MySQL/PHP Help

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 &reg;</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:&nbsp </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:&nbsp&nbsp </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.
hunna03 is offline   Reply With Quote