Hi There,
Ive been searching everywhere in google but i got nothing. What i need is to be able display user datail after he login on a certain textbox
Login.php page code:
<?php
session_start();
ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<?php
//This displays your login form
function index(){
echo "<form action='?act=login' method='post' id='login'>"
." Username: <input type='text' name='username' size='30'><br/><br/>"
." Password: <input type='password' name='password' size='30'><br/><br/>"
." <input type='submit' value='Login' id='submit'><br/>"
."</form>";
}
//This function will find and checks if your data is correct
function login(){
//Collect your info from login form
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
//Connecting to database
$connect = mysql_connect("localhost","user","pass");
if(!$connect){
die(mysql_error());
}
//Selecting database
$select_db = mysql_select_db("db_name", $connect);
if(!$select_db){
die(mysql_error());
}
//Find if entered data is correct
$result = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'");
$row = mysql_fetch_array($result);
$id = $row['id'];
$select_user = mysql_query("SELECT * FROM users WHERE id='$id'");
$row2 = mysql_fetch_array($select_user);
$user = $row2['username'];
if($username != $user){
die("Username is wrong!");
}
$pass_check = mysql_query("SELECT * FROM users WHERE username='$username' AND id='$id'");
$row3 = mysql_fetch_array($pass_check);
$email = $row3['email'];
$select_pass = mysql_query("SELECT * FROM users WHERE username='$username' AND id='$id'");
$row4 = mysql_fetch_array($select_pass);
$real_password = $row4['password'];
if($password != $real_password){
die("Your password is wrong!");
}
//Now if everything is correct let's finish his/her/its login
session_register("username", $username);
session_register("password", $password);
$url='/user_index.php';
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
}
switch($act){
default:
index();
break;
case "login":
login();
break;
}
?>
</body>
</html>
I need the details from the user database to be display is the data from "station" col_name.
report.php code
<?php
session_start();
ob_start();
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form action= "insert.php" method="post" enctype="multipart/form-data">
<label for='station'>Station: </label>
<!-- on this station text box where i want to put $_SESSION["station"] that will automaticaly called from the user db and send info on report db-->
<input type="text" name="stations" size="60" height="100" maxlength="50">
<br>
<label for='title:'> Title: </label>
<select name="title">
<option value="">Select...</option>
<option value="personnel_profile">Personnel Profile</option>
<option value="Monthly Fire Incidents Reports">Monthly Admin Report</option>
<option value="Reports">Weekly Admin Report</option>
<option value="Reports"> Weekly Activities</option>
<option value="Reports">Fire Code Fees</option>
<option value="Reports"> Inspection Report</option>
<option value="Reports"> Fire Incident Report</option>
<option value="Reports">Fuel Consumption Report</option>
</select>
<label for='detail'>Detail: </label>
<textarea name="detail" rows="10" cols="45" maxlength="1000"></textarea>
<script type="text/javascript">
function show_confirm()
{
var r=confirm("Do you wish to send the file");
if (r==true)
{
return true;
alert("File has been sent!");
}
else
{
return false;
}
return false;
}
</script>
Please choose a file: <input name="uploaded" type="file" />
<input type="submit" value="Upload" onclick='return show_confirm();'/>
</form>
</body>
</html>