Validation code - What is missing ?
Posted by: edocphp (208.250.63.---)
Date: April 16, 2008 07:16PM

<?php

$con = mysql_connect("localhost", "user","password"winking smiley or die('Could not connect to server') ;
mysql_select_db("database",$con) or die('Could not connect to database');

$userid = $_POST['userid'];
$password = $_POST['password'];

$query = "SELECT userid FROM users WHERE userid = '$userid' and password = PASSWORD('$password')";
$result = mysql_query($query);

if (mysql_num_rows($result) == 0)
{
echo "Sorry, your user account was not validated.\n";
echo "<a href =\"index.php?content=login\">Try again</a><br>\n";
echo "<a href =\"index.php\">Return to Home</a>\n";
}
else{
$_SESSION['valid_user'] = $userid;
echo "Your user account has been validated.<br>\n";
echo "<a href =\"index.php\">Return to Home</a>\n";
}
?>

Options: ReplyQuote
Re: Validation code - What is missing ?
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: April 16, 2008 07:33PM

whats the errror ur getting?

$query = "SELECT userid FROM users WHERE userid = '$userid' and password = PASSWORD('$password')";


should it not be

$query = "SELECT userid FROM users WHERE userid = '$userid' and password = '$password'";

Options: ReplyQuote
Re: Validation code - What is missing ?
Posted by: edocphp (208.250.63.---)
Date: April 16, 2008 11:09PM

Parse error: syntax error, unexpected T_ELSE

Options: ReplyQuote
Re: Validation code - What is missing ?
Posted by: miiikkeyyyy (---.leed.adsl.virgin.net)
Date: April 16, 2008 11:45PM

Try this mate.

<?php

$con = mysql_connect("localhost", "user","password"winking smiley or die('Could not connect to server') ;
mysql_select_db("database",$con) or die('Could not connect to database');

$userid = $_POST['userid'];
$password = PASSWORD($_POST['password']);

$query = "SELECT userid, password FROM users WHERE userid = '$userid' and password = '$password'";
$result = mysql_query($query);

if (mysql_num_rows($result) == 0)
{
echo "Sorry, your user account was not validated.\n";
echo "<a href =\"index.php?content=login\">Try again</a><br>\n";
echo "<a href =\"index.php\">Return to Home</a>\n";
}
else{
$_SESSION['valid_user'] = $userid;
echo "Your user account has been validated.<br>\n";
echo "<a href =\"index.php\">Return to Home</a>\n";
}
?>

Options: ReplyQuote
Re: Validation code - What is missing ?
Posted by: miiikkeyyyy (---.leed.adsl.virgin.net)
Date: April 16, 2008 11:45PM

also, im pressuming that PASSWORD is a function you created?



Edited 1 time(s). Last edit at 04/16/2008 11:46PM by miiikkeyyyy.

Options: ReplyQuote
Re: Validation code - What is missing ?
Posted by: edocphp (208.250.63.---)
Date: April 17, 2008 12:52AM

Thank you !!



Parse error: syntax error, unexpected T_ELSE


Got past one error. However for some reason it does not like the else part of the ....if else.

Options: ReplyQuote
Re: Validation code - What is missing ?
Posted by: miiikkeyyyy (---.leed.adsl.virgin.net)
Date: April 17, 2008 01:43PM

What line does it say the error is on?
I've run your code, and the only errors I get are the face there is no PASSWORD function and that there is no results...

Thats because I dont have the database.
Other than that, your script worked absolutly fine mate.

Options: ReplyQuote
Re: Validation code - What is missing ?
Posted by: edocphp (208.250.63.---)
Date: April 17, 2008 07:05PM

else { line is the beginning of the next error message. Thinking this could have something to do with the SESSION portion under the statement ?

Options: ReplyQuote
Re: Validation code - What is missing ?
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: April 17, 2008 07:10PM

dunno lol. Try look up $ cookie ..

Options: ReplyQuote


Sorry, only registered users may post in this forum.