Code not working - help
Posted: Thu Apr 13, 2006 11:47 am
feyd | Please use
However it just passes me to the else statement at the end of the codeing every time. There is data in both tables and i can send and retrieve data from these files however this script doesnt seem to work....... Please if anyone has an idea as to why it isnt working please tell me....
Distraught newbie
Stephen
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I have got this codeing to search two mysql Username and password tables and depending on which table the data is found on - pass the user to a different webpage.Code: Select all
<?
echo "username" .
$_REQUEST["username"] . " was selected."; // use this to declare the variable "date" in your
echo "<BR>"; // case it will be $_REQUEST["Username"]
echo "password" .
$_REQUEST["password"]. " was seleted."; // same thing again here, u change urs to $_REQUEST["Password"]
echo "<BR>"; // i used the echos to make sure that i was passing the correct values
$username = $_REQUEST["username"]; // here i just made the variable easier to type into my code
$password = $_REQUEST["password"];
// Make a MySQL Connection
mysql_connect("localhost", "s14633902", "230683") or die(mysql_error());
mysql_select_db("s14633902")
or die(mysql_error());
function AuthUser($tableName,$username,$password)
{
global $dbLink;
if (!($result = @mysql_query("SELECT * FROM $tableName where username='$username' AND password = '$password'",$dbLink)))
{
return 0;
}
if (($row = @mysql_fetch_array($result)) && ($password == $row["password"] && $password != ""))
return 1;
else
return 0;
}
if(AuthUser("newlogin",$username,$password))
{
// Redirect to home page
echo "<p class=data> <center>Successfully,Logged in<br><br><a href='Log out.php'> Log OUT </a><br><br><a href=home.htm>Click here if your browser is not redirecting automatically or you don't want to wait.</a><br></center>";
print "<script>";
print " self.location='home.htm';"; // re-direct
print "</script>";
}elseif(AuthUser("piclogin",$username,$password))
{
// Redirect to Registration page
echo "<p class=data> <center>Successfully,Logged in<br><br><a href='Log out.php'> Log OUT </a><br><br><a href=Registration>Click here if your browser is not redirecting automatically or you don't want to wait.</a><br></center>";
print "<script>";
print " self.location='Registration.php';"; // re-direct
print "</script>";
}else{
// Redirect to login page
echo "<font face='Verdana' size='2' color=red><center>Wrong Login. Please Enter your Username and Password and Try Again </center><br><p> </p><center><input type='button' value='Retry' onClick='history.go(-1)'></center>";
}
?>However it just passes me to the else statement at the end of the codeing every time. There is data in both tables and i can send and retrieve data from these files however this script doesnt seem to work....... Please if anyone has an idea as to why it isnt working please tell me....
Distraught newbie
Stephen
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]