This shouldn't be too hard. I have a login page, when the user click submit it checks the login success:
<?php
ob_start();
$host="db";
$username="username";
$password="password";
$db_name="mydb";
$tbl_name="table";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$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'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("myusername");
session_register("mypassword");
header("location:main.php");
echo "<h2>Welcome " . $sql['id'] . "</h2>"; // I want to use the contents of this var in main.php
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
?>
Upon login success it redirects to main.php
In main.php I want to read $sql['id'].
How do I go about doing this?

New Topic/Question
Reply



MultiQuote







|