Butler Posted April 24, 2011 Share Posted April 24, 2011 <?php include ('connection.php'); $username=$_POST['username5']; $password=$_POST['password5']; $query="SELECT password FROM merchants WHERE username = '$_POST(username5)'"; if ($password == $query) { $url = "SELECT url FROM merchants WHERE username = '$_POST(username5)'"; header("Location: $url"); } else { //change later echo urgh } ?> I am self taught and am trying to figure soe things out and i am unable to get this to work. Can anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/234580-need-help/ Share on other sites More sharing options...
bamfon Posted April 24, 2011 Share Posted April 24, 2011 There no point telling it user $username=$_POST['username5']; then using $_POST['username5']; in the query <?php include ('connection.php'); $username=$_POST['username5']; $password=$_POST['password5']; $query="SELECT password FROM merchants WHERE username = '$username'"; if ($password == $query) { $url = "SELECT url FROM merchants WHERE username = '$username'"; header("Location: $url"); } else { //change later echo urgh; } ?> What error are you getting? You could use the one below thats working it will do the same thing as your one <?php $username = $_POST['username']; $password = $_POST['password']; $sql="select * from merchants WHERE username='$username' and password='$password' "; $res=mysql_query($sql); if(!$res) { die('error loging'); } $row=mysql_fetch_array($res); if(mysql_num_rows($res)>0) { $url = "SELECT url FROM merchants WHERE username = '$username'"; header("Location: $url"); } else {//change later echo urgh; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/234580-need-help/#findComment-1205537 Share on other sites More sharing options...
ManiacDan Posted May 4, 2011 Share Posted May 4, 2011 You're not actually RUNNING these queries. Right now you just have strings and you're trying to see if the password is equal to the full SELECT statement to view the password. That would be a funny coincidence, but is not what you want. Also, don't do passwords like this. Use a one-way hash like sha1 with a salt to encrypt the password so you cannot view them and nobody can steal them. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/234580-need-help/#findComment-1210258 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.