Hi, This is my version of a user script.

panel.php (Logged in Page)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>C&amp;C-Relived Control Panel</title>

<span style="color:  #FFF">Login Successful</span>
<form name="form1" method="post" action="logout.php">
<input type="submit" name="Submit" value="Log Out">
If you can see this page then you have sucessfully logged in<br /><br />


$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");

// username and password sent from form

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

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";

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

// Register $myusername, $mypassword and redirect to file "login_success.php"
else {
echo "<strong>Wrong Username or Password</strong>";

Now, i want to add a "welcome (logged in name), you are logged in"

Any Ideas?

Hi Commando112,

You already have the username stored as a session variable so you can just echo "Welcome " . $_SESSION['myusername']; You may want to remove the extra </body> tag on line 22 of panel.php. You are also using a few deprecated session functions so you may want to update them.

So, what do i use? i have basic knowledge of php.

Hi again,

You can set session variables with $_SESSION['myusername'] == "Commando112"; instead of session_register("myusername"); You can check if a variable is (not) set with if(!isset($_SESSION['myusername'])){ instead of if(!session_is_registered(myusername)){

So doe it matter if i keep using deprecated code? like will it be unsupported in the future?


It's unsupported from PHP5.3 (I think) so it's possible for the feature to be removed from future versions of PHP. It's always best to roll with the flow :)