I need ur help guys .. did the creation of the site for "home docking ideas". I have a login form (login-form.php) in which, after entering the "login" and "password" after checking through login-execute.php, it is redirected to viewOrder.php, where the user can view all orders ordered by customers .. everything is still fine .. but what I want when a user logs in, he only looks at this order, which is not ordered by him in all client orders. The database contains two tables: members and order_insert .. in the table "members", the login and password are stored and in "order_insert" customer orders are stored .. the codes of these three pages are as follows.
.........................
login-form.php
.........................
<form id="loginForm" name="loginForm" method="post" action="login-exec.php">
<table width="300" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="112"><b>Login</b></td>
<td width="188"><input name="login" type="text" class="textfield" id="login" /></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input name="password" type="password" class="textfield" id="password" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Login" /></td>
</tr>
</table>
</form>
......................... Login-execute.php .................... .....
<?php
session_start();
require_once('config.php');
$errmsg_arr = array();
$errflag = false;
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
$login = clean($_POST['login']);
$password = clean($_POST['password']);
if($login == '') {
$errmsg_arr[] = 'Login ID missing';
$errflag = true;
}
if($password == '') {
$errmsg_arr[] = 'Password missing';
$errflag = true;
}
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: login-form.php");
exit();
}
$qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'";
$result=mysql_query($qry);
if($result) {
if(mysql_num_rows($result) == 1) {
session_regenerate_id();
$member = mysql_fetch_assoc($result);
$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
$_SESSION['SESS_FIRST_NAME'] = $member['firstname'];
$_SESSION['SESS_LAST_NAME'] = $member['lastname'];
session_write_close();
header("location: viewOrder.php");
exit();
}else {
header("location: login-failed.php");
exit();
}
}else {
die("Query failed");
}
?>
.............................
viewOrder.php
..............................
<html>
<body bgcolor="#FFFFFF" >
<?
$host="localhost";
$username="root";
$password="";
$db_name="mydatabase";
$tbl_name="order_insert";
$tbl_name2="members";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$result = mysql_query("SELECT * FROM $tbl_name ");
print "<center>";
$output .= "<table width=1100 border=1 bordercolor=black>";
$output .= "<tr align=center><td>ID</td><td>First Name</td><td>Last Name</td><td>E Mail</td><td> City </td><td> Country </td><td> Phone</td><td>Decoration Type</td><td>Service Description</td><td>Budget</td><td>Update</td><td>Delete</td></tr>";
$output .= "<th></th><th></th>";
$output .= "</tr>\n\n";
while ($row = mysql_fetch_assoc($result)){
$output .= "<tr>\n";
foreach ($row as $col=>$val){
$output .= " <td>$val</td>\n";
}
$keyVal = $row["id"];
$output .= "<td><a href='update.php?ID=$row[orderId]' >Update </a></td>";
$output .= "<td><a href='delete.php?ID=$row[orderId]' >Delete </a></td>";
$output .= "</tr>\n\n";
}
$output .= "</table></center>";
print "$output";
?> <br>
<br>
<center><table > <tr><td>
<form action="home.php"><font color="#FF0000"><input type="submit" name="btn" style="color:#CC0000" value="<--Back" ></font></form></td></tr></table></center>
</body>
</html>
.....