harshadmethrath Posted October 6, 2010 Share Posted October 6, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/215298-signup-works-login-doesnt/ Share on other sites More sharing options...
Pikachu2000 Posted October 7, 2010 Share Posted October 7, 2010 These 2 lines don't make much sense together. The second conditional is redundant and would be better as a count of the records returned to verify that one and only one record matched. if($rec=mysql_fetch_array(mysql_query("SELECT * FROM plus_signup WHERE userid='$userid' AND password = '$password'"))){ if(($rec['userid']==$userid)&&($rec['password']==$password)){ Quote Link to comment https://forums.phpfreaks.com/topic/215298-signup-works-login-doesnt/#findComment-1119655 Share on other sites More sharing options...
chintansshah Posted October 7, 2010 Share Posted October 7, 2010 I am eager to know from where you set these two variables $userid and $password, I can't see any $_POST, $_GET or $_REQUEST. $userid=mysql_real_escape_string($userid); $password=mysql_real_escape_string($password); Quote Link to comment https://forums.phpfreaks.com/topic/215298-signup-works-login-doesnt/#findComment-1119693 Share on other sites More sharing options...
harshadmethrath Posted October 7, 2010 Author Share Posted October 7, 2010 @ Chintan, Picachu I am not a php guy. I am just learning the basics. I used a sign up and login page that i found online. the sign up page works fine but the login creates the issue...i will attach the files here..if u wanna look. ur efforts are appreciated very much [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/215298-signup-works-login-doesnt/#findComment-1119781 Share on other sites More sharing options...
PFMaBiSmAd Posted October 7, 2010 Share Posted October 7, 2010 It doesn't do us any good to just tell us some code doesn't work. We already know that because you wouldn't be posting on a programming help forum if your code worked. You have got to tell us what you see in front of you when you tried it. You could be getting a blank page, a php error, a mysql error, an error message from the application or any number of other symptoms that would tell us what might be the problem with your code on your server with your database. Quote Link to comment https://forums.phpfreaks.com/topic/215298-signup-works-login-doesnt/#findComment-1119788 Share on other sites More sharing options...
Pikachu2000 Posted October 7, 2010 Share Posted October 7, 2010 Instead of trying to learn php by downloading scripts and trying to install and run them, you'd be better off to find some good tutorials, or buy a book to read. Much of the code you'll find online is either old and obsolete, or has security issues. Quote Link to comment https://forums.phpfreaks.com/topic/215298-signup-works-login-doesnt/#findComment-1119828 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.