Jump to content

Need help


Butler

Recommended Posts

<?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?

 

Link to comment
Share on other sites

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;
}

?>

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.