pravin_fer Posted August 15, 2006 Share Posted August 15, 2006 hello folks i am new to phpi have created a log on script to check userid and password from mysql database, but even if i enter correct uesrname and password it doesnt display correct messageplse help me<?php include 'database_connect.private'; ?> <?php $pid=$_POST["UserID"]; $passwrd=$_POST["PassWord"]; //$flag=false; error_reporting(1); session_start(); header("Cache-control: private"); $connection = mysql_connect($hostname,$username,$password); mysql_select_db($databaseName, $connection); /* $result = mysql_query ("SELECT * FROM staff", $connection); while ($row = mysql_fetch_row($result)) { echo "hello"; if($pid==$row[0] && $passwrd==$row[1]) {echo "hello"; $flag=true; } }*/ //if(isset($_POST['submit']) //{ $query="SELECT * FROM staff WHERE staff_Id ='$pid' AND password='$passwrd' "; $result=mysql_query($query); //or die(mysql_error()); echo "try"; if (mysql_num_rows($result)==1) { echo "user logged in"; $_SESSION['user_logged']=$_POST['user_Id']; $_SESSION['user_password']=$_POST['password']; echo "Successful login ... Click Here to "; //redirect ("http://stuweb.cms.gre.ac.uk/~fj330/home.html") } else { echo "<p> Sorry Unauthorized Access is not Allowed</p>"; } //mysql_close($connection); ?> Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 15, 2006 Share Posted August 15, 2006 test your query in phpmyadmin or similar and see what is returned...(echo out your query string before you run the query - then you can copy and paste into your favorite db app!) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.