|
-
May 1st, 2007, 07:43 PM
#1
Thread Starter
Member
log in problem
Hi
could anyone please help me to sort out this proble, when I try to execute
the error query not excuted, i know that the proble is the sekect command
but no clue what is it!!
PHP Code:
<?php // script to check if the user stored in the MySQL database previously
session_start();
include "conn.inc.php";
if(isset($_POST['submit']))
{
$query = "select username, password from user" .
"where username = '" . $_POST['username'] . "' " . "ADN password = (PASSWORD('" . $_POST['password'] . " '))";
// excute the query
$result = mysql_query($query)
or die("query not excuted!");
if(mysql_num_rows($result) == 1)
{
$_SESSION['user_logged'] = $_SESSION['username'];
$_SESSION['user_password'] = $_SESSION['password'];
header("Refresh: 5; URL=" . $_POST['redirect'] . "");
echo " you being redirected to your original page reques<br>";
echo "(if your browser not support this, " .
"<a href =\"" . $_POST['redirect'] . "\"> Click here</a>)";
}
else
{
?>
<html>
<head><title> user_login</title></head>
<body>
<p>
invalid and /or password<br>
Not registered?
<a href="register.php">Click here</a> to register.<br>
<form action="user_login.php" method="POST">
<input type="hidden" name="redirect" value="<?php echo $_POST ['redirect']; ?>">
Username : <input type="text" name="username"><br>
Password : <input type="password" name="password"><br><br>
<input type="submit" name="submit" value="Login">
</form>
</p>
</body>
</html>
<?php
}
}
else
{
if(isset($_GET['redirect']))
{
$redirect = $_GET['redirect'];
}else
{
$redirect ="index1.php";
}
?>
<html>
<head><title>Management system </title></head>
<body>
<p>
login below by supplying your username/password..<br>
or<a href="register.php"> Click here</a> to register.<br><br>
<form action="user_login.php" method="POST">
<input type="hidden" name="redirect" value="<?php echo $redirect; ?>">
Username : <input type="text" name="username"><br>
Password : <input type="password" name="password"><br><br>
<input type="submit" name="submit" value="Login">
</form>
</p>
</body>
</html>
<?php
}
?>
-
May 2nd, 2007, 04:30 AM
#2
Re: log in problem
PHP Code:
$query = "select username, password from user" .
"where username = '" . $_POST['username'] . "' " . "ADN password = (PASSWORD('" . $_POST['password'
you need a space after user, so,
PHP Code:
$query = "select username, password from user" .
" where username = '" . $_POST['username'] . "' " . "ADN password = (PASSWORD('" . $_POST['password'
otherwise your executing,
PHP Code:
select username, password from userwhere username= etc...
instead of,
PHP Code:
select username, password from user where username= etc...
-
May 2nd, 2007, 08:26 AM
#3
Re: log in problem
would you please quit making new threads over and over again? you must have made 10 topics in the past week about the same questions, over and over. reply to your old topic, don't make a new one.
now, if you just look through your own code you cna figure out these problems for yourself. you spelled "AND" wrong (and put ADN), and you have a space before you close the call for "PASSWORD()", which means that you're appending a space to everyone's password (making them incorrect, basically). change to:
PHP Code:
$query = "select username, password from user " .
"where username = '" . $_POST['username'] . "' AND password = (PASSWORD('" . $_POST['password'] . "'))";
-
May 2nd, 2007, 12:29 PM
#4
Re: log in problem
 Originally Posted by omarali
Hi
could anyone please help me to sort out this proble, when I try to execute
the error query not excuted, i know that the proble is the sekect command
but no clue what is it!!
PHP Code:
<?php // script to check if the user stored in the MySQL database previously
session_start();
include "conn.inc.php";
if(isset($_POST['submit']))
{
$query = "select username, password from user" .
"where username = '" . $_POST['username'] . "' " . "ADN password = (PASSWORD('" . $_POST['password'] . " '))";
// excute the query
$result = mysql_query($query)
or die("query not excuted!");
if(mysql_num_rows($result) == 1)
{
$_SESSION['user_logged'] = $_SESSION['username'];
$_SESSION['user_password'] = $_SESSION['password'];
header("Refresh: 5; URL=" . $_POST['redirect'] . "");
echo " you being redirected to your original page reques<br>";
echo "(if your browser not support this, " .
"<a href =\"" . $_POST['redirect'] . "\"> Click here</a>)";
}
else
{
?>
<html>
<head><title> user_login</title></head>
<body>
<p>
invalid and /or password<br>
Not registered?
<a href="register.php">Click here</a> to register.<br>
<form action="user_login.php" method="POST">
<input type="hidden" name="redirect" value="<?php echo $_POST ['redirect']; ?>">
Username : <input type="text" name="username"><br>
Password : <input type="password" name="password"><br><br>
<input type="submit" name="submit" value="Login">
</form>
</p>
</body>
</html>
<?php
}
}
else
{
if(isset($_GET['redirect']))
{
$redirect = $_GET['redirect'];
}else
{
$redirect ="index1.php";
}
?>
<html>
<head><title>Management system </title></head>
<body>
<p>
login below by supplying your username/password..<br>
or<a href="register.php"> Click here</a> to register.<br><br>
<form action="user_login.php" method="POST">
<input type="hidden" name="redirect" value="<?php echo $redirect; ?>">
Username : <input type="text" name="username"><br>
Password : <input type="password" name="password"><br><br>
<input type="submit" name="submit" value="Login">
</form>
</p>
</body>
</html>
<?php
}
?>
If you use mysql error, you might be able to find out what your error is all by yourself 
PHP Code:
echo(mysql_error());
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|