Hi,
I am currently creating a simple prototype website as part of my research project for my degree. I have found tutorials for most things on the web but am having a few issues with some code with regard to getting some values from the user database in MySQL once the user logs.
Currently i have:
<?php
$host="localhost";
$username="root";
$password="root";
$db_name="research";
$tbl_name="users";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$username=$_POST['username'];
$password=$_POST['password'];
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("myusername");
session_register("mypassword");
header("location:../data.php");
}
else {
echo "Wrong Username or Password";
}
?>
And the following code is in approve.php which is included in all pages that have protected data:
<?
session_start();
if(!session_is_registered(username)){
header("location:login.php");
}
?>
What i am looking to do are the following:
1 - use the details from the session to be able to display users information
2 - use the details from the session to pull some of the values for use in calculations carried out by some php calculators
Any help would be amazing, and thanks in advance.
Will