Jump to content

Login Management


ublapach

Recommended Posts

code to authentication page is

 

<?php
session_start();

$errorMessage = '';
if (isset($_POST['Submit'])) {
   
   $username=$_POST['username'];
   $passwd=$_POST['passwd'];
   
   include '../tracking/db_connx.php';

   $sql = "SELECT * FROM webusers WHERE username = '$username' AND passwd = '$passwd'" 
   
   or die("error 1");

   $result = mysql_query($sql)
             or die('Query failed. ' . mysql_error());

   if (mysql_num_rows($result) == 1) {

     echo"Loged In";

      
      /* UNCOMMENT THIS LATER
      
      $_SESSION['db_is_logged_in'] == true; 

      header('Location:../indexin.php');
      exit;
      
      */
   } else {
   
      $echo = 'Sorry, wrong user id / password';
   }

}
?>

 

 

code to check wheather your logged in or not

 

<?php
session_start();

// is the one accessing this page logged in or not?
if (!isset($_SESSION['db_is_logged_in'])
   || $_SESSION['db_is_logged_in'] !== true) {

   // not logged in, move to login page
   header('Location: indexlog.php');
   exit;
}

?>

Link to comment
Share on other sites

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Make a new file and put this code and only this code in it...

 

Be sure --include '../tracking/db_connx.php';-- is still correct

 

 

<?php
session_start();

$errorMessage = '';

if (isset($_POST['Submit'])) {
   
   $username=$_POST['username'];
   $passwd=$_POST['passwd'];
   
   include '../tracking/db_connx.php';

   $sql = "SELECT * FROM webusers WHERE username = '$username' AND passwd = '$passwd'" 
   
   or die("error 1");

   $result = mysql_query($sql)
             or die('Query failed. ' . mysql_error());

   $count=mysql_num_rows($result);

     if($count==1){

     echo"Loged In";

      
      /* UNCOMMENT THIS LATER
      
      $_SESSION['db_is_logged_in'] == true; 

      header('Location:../indexin.php');
      exit;
      
      */
   } else {
   
      $echo = 'Sorry, wrong user id / password';
   }

}
?>
<p>
<form id="login" name="login" method="POST" action="">
<input type="text" id="username" name="username" value="User Name" />
<input type="password" id="passwd" name="passwd" value="Password"/>
<input type="submit" id="submit" name=Submit value="Log In"/>
</form>      
</p>

 

 

 

Link to comment
Share on other sites

  <p>
              <form id="login" name="login" method="POST" action="login/authuser.php">
		    <input type="text" id="username" name="username" value="User Name" />
		    <input type="password" id="passwd" name="passwd" value="Password"/>
		    <input type="submit" id="submit" name="Submit" value="Log In"/>
	      </p>

Link to comment
Share on other sites

if (isset($_POST['Submit']))
{
if ($_POST['username'] == $username && $_POST['passwd'] == $passwd)
{
	header("location: //wherever your main page is located");
}
else
{
	header("location: //location of your login page");
}
}

Link to comment
Share on other sites

<?php
session_start();

$errorMessage = '';
if (isset($_POST['Submit'])) {
   
   $username=$_POST['username'];
   $passwd=$_POST['passwd'];
   
   include '../tracking/db_connx.php';

   $sql = "SELECT * FROM webusers WHERE username = '$username' AND passwd = '$passwd'" 
   
   or die("error 1");

   $result = mysql_query($sql)
             or die('Query failed. ' . mysql_error());

   $count=mysql_num_rows($result);

     if (isset($_POST['Submit']))
{
if ($_POST['username'] == $username && $_POST['passwd'] == $passwd)
{
	header("location: ../indexin.php");
}
else
{
	header("location: ../indexlog.php");
}
}
?>

Link to comment
Share on other sites

<?php
session_start();

$errorMessage = '';
if (isset($_POST['Submit']))
{
if ($_POST['username'] == $username && $_POST['passwd'] == $passwd)
{
	header("location: ../indexin.php");
}
else
{
	header("location: ../indexlog.php");
}
}
   
   include '../tracking/db_connx.php';

   $sql = "SELECT * FROM webusers WHERE username = '$username' AND passwd = '$passwd'" 

   $result = mysql_query($sql);

   $count=mysql_num_rows($result);

?>

Link to comment
Share on other sites

still getting error

 

Notice: Undefined variable: username in /usr/home/jlytal/public_html/newsite/login/authuser.php on line 22

 

Notice: Undefined variable: passwd in /usr/home/jlytal/public_html/newsite/login/authuser.php on line 22

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • 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.