Jump to content

Recommended Posts

Here is the code from the checkuser.php

 

<?

/* Check User Script */

session_start();  // Start Session

 

include 'db.php';

// Conver to simple variables

$username = $_POST['username'];

$password = $_POST['password'];

 

if((!$username) || (!$password)){

echo "Please enter ALL of the information! <br />";

include 'Client_ActErr.php';

exit();

}

 

// Convert password to md5 hash

$password = md5($password);

 

// check if the user info validates the db

$sql = mysql_query("SELECT * FROM Clients WHERE username='$username' AND password='$password' AND activated='1'");

$login_check = mysql_num_rows($sql);

 

if($login_check > 0){

while($row = mysql_fetch_array($sql)){

foreach( $row AS $key => $val ){

$$key = stripslashes( $val );

}

// Register some session variables!

session_register('first_name');

$_SESSION['first_name'] = $first_name;

session_register('last_name');

$_SESSION['last_name'] = $last_name;

session_register('email_address');

$_SESSION['email_address'] = $email_address;

session_register('special_user');

$_SESSION['user_level'] = $user_level;

 

mysql_query("UPDATE Clients SET last_login=now() WHERE pk_client_id ='$userid'");

 

header("Location: index.html");

}

} else {

//echo "You could not be logged in! Either the username and password do not match or you have not validated your registration!<br />

//Please try again!<br />";

include 'Client_ActErr.php';

}

?>

Here's what i have...

 

<div id = "leftside">

    <p>          <span class="style14 style5 style15"><a href="client_page.php"><img src="media/client_login_ov.gif" width="180" height="28" border="0"></a></span><a href="#"></a><br>

  <br>

  <?

    if(!$first_name){

echo $_SESSION['first_name'];

<br />

}

?>

<?php  // <--- always use full tag syntax
        session_start();  // <--- must include session_start() before using session data
        if(!$first_name){ // <--- this appears to be undefined, therefore will always return TRUE
         echo $_SESSION['first_name'];
         <br />
         }
      ?>

I used this script on my own website and its working. coded by myself though :D

<?php
session_start();

if(!isset($_SESSION['first_name'])){


echo "<form action='checkuser.php' method='post' name='login'>
Username:<br><input class='login' name='username' type='text' value=''>
Password:<br><input class='login' name='password' type='password' value=''><br><input name='Submit' type='submit' value='SUBMIT!'>
</form>";
}
else {

echo "<center> Welcome, ";
echo ($_SESSION['first_name']);
}
?>

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.