need help with PHP mysql, please need some advce.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dfgdgdfgdfg
Forum Newbie
Posts: 3
Joined: Tue Dec 09, 2008 2:42 am

need help with PHP mysql, please need some advce.

Post by dfgdgdfgdfg »

for some reason my code do not return any value. it is a simple login script. just check the username and password.

*****this is my php page NAME: auth1.php**************

Code: Select all

<html>
<body>
<?
$user = $_POST['user']; //post user name
$pass = $_POST['pass']; // post pass
 
 
 
$connection = mysql_connect(localhost, "", "");
mysql_select_db('login') or die("cannot select a database");
 
$get = mysql_query(SELECT * FROM login_info WHERE usr = '$user' and pass = '$pass'); 
$result =mysql_result($get, 0);
$close = mysql_close($connection);
 
if ($result != 1) echo "login failure";
else {
echo "Suceess";
};
 
 
?>
</body>
</html>
----------------------------------------------------------
******this is my form page : login_page.php ***********************

Code: Select all

<form action="auth1.php" method="post" name= "form1">
 
User name <input type="text" name = "user" />
Password <input type="text" name = "pass" />
<input type="submit" value = "submit" />
</form>
please help
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: need help with PHP mysql, please need some advce.

Post by requinix »

You can't even bother creating a decent username.

Code: Select all

$get = mysql_query(SELECT * FROM login_info WHERE usr = '$user' and pass = '$pass');
There's the problem.
dfgdgdfgdfg
Forum Newbie
Posts: 3
Joined: Tue Dec 09, 2008 2:42 am

Re: need help with PHP mysql, please need some advce.

Post by dfgdgdfgdfg »

in my code, in line 12, i already wrote that line you suggested. still not working, please help.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: need help with PHP mysql, please need some advce.

Post by requinix »

dfgdgdfgdfg wrote:in my code, in line 12, i already wrote that line you suggested. still not working, please help.
Not a very good suggestion when it's accompanied by the words "there's the problem". It was more like I pointed out that there's something wrong with it.

If you have a reasonable amount of PHP experience you should be able to look at the code and see what's wrong with it. There's even some highlighting to help you (hint: the query should be in red).
And yes, I'm biased against you.
dfgdgdfgdfg
Forum Newbie
Posts: 3
Joined: Tue Dec 09, 2008 2:42 am

Re: need help with PHP mysql, please need some advce.

Post by dfgdgdfgdfg »

it is not nice of you that you were biased againt me just because I have poor knowledge of PHP. you can just explain what the problem in my code rather than critisizing my ability, it would have been nice. thanks
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: need help with PHP mysql, please need some advce.

Post by requinix »

dfgdgdfgdfg wrote:it is not nice of you that you were biased againt me just because I have poor knowledge of PHP. you can just explain what the problem in my code rather than critisizing my ability, it would have been nice. thanks
No, I'm biased against you because when signing up for this site you put no effort into creating a username and simply hit the letters d, f, and g repeatedly.

Fine.

Code: Select all

$get = mysql_query(SELECT * FROM login_info WHERE usr = '$user' and pass = '$pass');
The query should be a string. Since it is not a string PHP thinks it's code. Which it is not. It has a fit over it and complains.

Code: Select all

$get = mysql_query("SELECT * FROM login_info WHERE usr = '$user' and pass = '$pass'");
See the change in highlighting?
cedartree
Forum Newbie
Posts: 10
Joined: Thu Dec 04, 2008 1:35 pm

Re: need help with PHP mysql, please need some advce.

Post by cedartree »

i agree with you tasairis,
nonetheless,
has this guy even run the query on his mysql database in order to create the username / password?

also, is the php file linked in to access the database?
Post Reply