How Do I Display The Currently Logged On Users Information?

Im Trying To Display The Users , Username, Phone Number, Name, Email… Etc… I Have Already Created The Tables But I Cant Get The Information Displayed On This Page.

checklogin.php
[php]
?php

$host="##########"; // Host name
$username="########"; // Mysql username
$password="######"; // Mysql password
$db_name="######_members"; // Database name
$tbl_name=“members”; // 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”);

// username and password sent from form
$myusername=$_POST[‘myusername’];
$mypassword=$_POST[‘mypassword’];

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$firstname = stripslashes($firstname);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$firstname = mysql_real_escape_string($firstname);

$sql=“SELECT * FROM $tbl_name WHERE username=’$myusername’ and password=’$mypassword’”;
$sqlinfo =“SELECT * FROM $tbl_name WHERE username=’$myusername’ and firstname=’$firstname’”;
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){

// Register $myusername, $mypassword and redirect to file “login_success.php”
session_register(“myusername”);
session_register(“mypassword”);
session_register(“firstname”);
header(“location:home.html”);
}
else {
echo “You Have Entered Incorrect Credentials. If You Have Forgot You Credentials Please Email Us.”;
}
?>

[/php]

myinfo.php
[php]

<?php session_start(); if(!session_is_registered(myusername)){ header("location:index.php"); } $host="##########"; // Host name $username="######s"; // Mysql username $password="######"; // Mysql password $db_name="#######_members"; // Database name $tbl_name="members"; // Table name mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); ?> <?php

echo “Your Name Is”.$_SESSION[‘firstname’];
?>

[/php]

Thank You In Advance :smiley:

Jordan

From the PHP website…

<?php // Use of session_register() is deprecated $barney = "A big purple dinosaur."; session_register("barney");

// Use of $_SESSION is preferred, as of PHP 4.1.0
$_SESSION[“zim”] = “An invader from another planet.”;

// The old way was to use $HTTP_SESSION_VARS
$HTTP_SESSION_VARS[“spongebob”] = “He’s got square pants.”;
?>
If session_start() was not called before this function is called, an implicit call to session_start() with no parameters will be made. $_SESSION does not mimic this behavior and requires session_start() before use.

Warning
This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.

Source.

Sponsor our Newsletter | Privacy Policy | Terms of Service