Jump to content

login script problem


dennissheats

Recommended Posts

I'm having problems validating login information against a mysql table. Here is the code. Any help would be appreciated.

 

Login Page (login.php)

<form action='loginck.php' method=post>

<table border='0' cellspacing='0' cellpadding='0'

 

  <tr> <td bgcolor='#f1f1f1' ><font face='verdana, arial, helvetica' size='2' align='center'>   Login ID     

</font></td> <td bgcolor='#f1f1f1' align='center'><font face='verdana, arial, helvetica' size='2' >

<input type ='text' class='bginput' name='initials' ></font></td></tr>

 

<tr> <td bgcolor='#ffffff' ><font face='verdana, arial, helvetica' size='2' align='center'>   Password 

</font></td> <td bgcolor='#ffffff' align='center'><font face='verdana, arial, helvetica' size='2' >

<input type ='password' class='bginput' name='password' ></font></td></tr>

 

<tr> <td bgcolor='#f1f1f1' colspan='2' align='center'><font face='verdana, arial, helvetica' size='2' align='center'> 

<input type='submit' value='Submit'> <input type='reset' value='Reset'>

</font></td> </tr>

 

Login Check Page (loginck.php)

<?php

$initials=('initials');

$password=('password');

$initials=mysql_real_escape_string($initials);

$password=mysql_real_escape_string($password);

 

if($rec=mysql_fetch_array(mysql_query("SELECT * FROM emp WHERE initials='$initials' AND password='$password'"))){

    if(($rec['initials']==$initials)&&($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';";

          print "</script>";

 

$_SESSION['id']=session_id();

$_SESSION['initials']=$initials;

 

                }

        } 

    else {

 

        session_unset();

echo "<font face='Verdana' size='2' color=red>Login Error. Use your correct  Userid and Password and Try Again <br>

<br><input type='button' value='Retry' onClick='history.go(-1)'></center>";

       

    }

   

 

 

?>

Link to comment
https://forums.phpfreaks.com/topic/98870-login-script-problem/
Share on other sites

YOu havent said what the problem is, but I am sure this is wrong:

 

$initials=('initials');
$password=('password');
$initials=mysql_real_escape_string($initials);
$password=mysql_real_escape_string($password);

 

should be

 

$initials = $_POST['initials'];
$password = $_POST[password'];
$initials = mysql_real_escape_string($_POST['$initials']);
$password = mysql_real_escape_string($_POST['$password']);

Link to comment
https://forums.phpfreaks.com/topic/98870-login-script-problem/#findComment-505908
Share on other sites

<form action='loginck.php' method=post>
<table border='0' cellspacing='0' cellpadding='0'

  <tr> <td bgcolor='#f1f1f1' ><font face='verdana, arial, helvetica' size='2' align='center'>   Login ID     
</font></td> <td bgcolor='#f1f1f1' align='center'><font face='verdana, arial, helvetica' size='2' >
<input type ='text' class='bginput' name='initials' ></font></td></tr>

<tr> <td bgcolor='#ffffff' ><font face='verdana, arial, helvetica' size='2' align='center'>   Password 
</font></td> <td bgcolor='#ffffff' align='center'><font face='verdana, arial, helvetica' size='2' >
<input type ='password' class='bginput' name='password' ></font></td></tr>

<tr> <td bgcolor='#f1f1f1' colspan='2' align='center'><font face='verdana, arial, helvetica' size='2' align='center'> 
<input type='submit' value='Submit'> <input type='reset' value='Reset'>
</font></td> </tr>

Login Check Page (loginck.php)
<?php
$initials=('initials');
$password=('password');
$initials=mysql_real_escape_string($initials);
$password=mysql_real_escape_string($password);

if($rec=mysql_fetch_array(mysql_query("SELECT * FROM emp WHERE initials='$initials' AND password='$password'"))){
    if(($rec['initials']==$initials)&&($rec['password']==$password)){
     include "include/newsession.php";
            echo "<p class=data> <center>Successfully,Logged in

<a href='logout.php'> Log OUT [/url]

<a href=welcome.php>Click here if your browser is not redirecting automatically or you don't want to wait.[/url]
</center>";
     print "<script>";
       print " self.location='welcome.php';";
          print "</script>";

$_SESSION['id']=session_id();
$_SESSION['initials']=$initials;

                }
        }   
    else {

        session_unset();
echo "<font face='Verdana' size='2' color=red>Login Error. Use your correct  Userid and Password and Try Again


<input type='button' value='Retry' onClick='history.go(-1)'></center>";
       
    }
   


?>

Link to comment
https://forums.phpfreaks.com/topic/98870-login-script-problem/#findComment-505912
Share on other sites

looking at that code there are syntax errors everywhere, you should spend sometime just looking at your syntax.

 

e.g:

 

<a href='logout.php'> Log OUT [/url]

<a href=welcome.php>Click here if your browser is not redirecting automatically or you don't want to wait.[/url]
</center>";

 

why does one "a href" have ' round the url and the other hasnt?

 

Where are the closing tags to the A HREF's ?

 

These are basic html problems not even php or mysql

Link to comment
https://forums.phpfreaks.com/topic/98870-login-script-problem/#findComment-505920
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.