Jump to content

Signup works - Login doesnt


harshadmethrath

Recommended Posts

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

Link to comment
Share on other sites

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)){

Link to comment
Share on other sites

@ 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]

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.