Page 1 of 1

Signup works - Login doesnt

Posted: Wed Oct 06, 2010 9:25 am
by harshadmethrath
heres the code for the login page ...i changed the server and username info for privacy

<?php

include "include/session.php";
$dbservertype='mysql';
$servername='supremeserver.com';
// username and password to log onto db server
$dbusername='newlogin';
$dbpassword='new18';
// name of database
$dbname='newlogin';

connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbusername,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbusername","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}

?>

<!doctype html public "-//w3c//dtd html 3.2//en">

<html>

<head>
<title>LOGIN</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<?php
$userid=mysql_real_escape_string($userid);
$password=mysql_real_escape_string($password);

if($rec=mysql_fetch_array(mysql_query("SELECT * FROM plus_signup WHERE userid='$userid' AND password = '$password'"))){
if(($rec['userid']==$userid)&&($rec['password']==$password)){
include "include/newsession.php";
echo "<p class=data> <center>Successfully,Logged in<br><br><a href='logout.php'> Log OUT </a><br><br><a href=welcome.php>Click here if your browser is not redirecting automatically or you don't want to wait.</a><br></center>";
print "<script>";
print " self.location='welcome.php';"; // Comment this line if you don't want to redirect
print "</script>";

}
}
else {

session_unset();
echo "<font face='Verdana' size='2' color=red>Wrong Login. Use your correct Userid and Password and Try <br><center><input type='button' value='Retry' onClick='history.go(-1)'></center>";

}
?>

</body>

</html>

_________________________________________________ _________________________________________________ __

your help is much appreciated

Re: Signup works - Login doesnt

Posted: Wed Oct 06, 2010 10:04 am
by twinedev
Are you just getting message saying the login is incorrect each time, are you getting errors? Can you post the code for adding the user to the database to compare methods (ie, are you really storing raw passwords which this code is looking for?)

(also, don't forget to use the PHP Code button in the editor to wrap code so it is more readable.)

-Greg