Jump to content

trying to display user details after login


anton_1

Recommended Posts

after the user has logged in, I would like to display their details by barcode id

 

 

Login.php

 

<?php

$host=""; // Host name

$username=""; // Mysql username

$password=""; // Mysql password

$db_name=""; // Database name

$tbl_name=""; // Table name

 

// Connect to server and select databse.

mysql_connect("$host", "$username", "$password")or die("cannot connect");

mysql_select_db("$db_name")or die("cannot select DB");

 

 

 

session_start();

// username and password sent from form

$barcodeID=$_POST['barcode'];

 

 

 

// To protect MySQL injection (more detail about MySQL injection)

$barcodeID = stripslashes($barcodeID);

$barcodeID = mysql_real_escape_string($barcodeID);

 

 

$sql="SELECT * FROM $tbl_name WHERE BarcodeID='$barcodeID'";

 

 

$result=mysql_query($sql);

   

$count=mysql_num_rows($result);

 

if($count > 0){

$data = mysql_fetch_array ($result);

 

$_SESSION["user_id"] = $data["BarcodeID"];

        $_SESSION["user_firstname"] = $data["Firstname"];

        $_SESSION["user_surname"] = $data["Surname"];

        $_SESSION["user_jobrole"] = $data["JobRole"];

        $_SESSION["user_manager"] = $data["Manager"];

        $_SESSION["user_priority"] = $data["Priority"];

        $_SESSION["user_datejoined"] = $data["DateJoined"];

        $_SESSION["user_times_loggged_in"] = $data["TimesLoggedOn"];

 

        if ($_SESSION["user_priority"] == '1')

        {

            header("Location: AdminSection.php");           

        }

        else

        {

header("Location:LoggedIn.php");

}

 

if ($_SESSION["user_times_loggged_in"] == '0')

{

 

header("Location:UsingTheSystem.html");

}

}

 

?>

 

 

 

LoggedIn.php

 

 

 

I keep getting the error undefined index "barcode"?

 

<?php

 

$barcodeID = $_POST["barcode"];

 

 

include 'dbcon.php';

 

    $sql = "SELECT Firstname, Surname, JobRole, Manager"

        . " FROM users"

        . " WHERE BarcodeID = .'$barcodeID'" ;

    $rows = mysql_query($sql);

   

    echo $rows;

   

    ?>

 

 

Any help will be greatly appreciated

 

 

Thanks

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.