下面的代码是我的表单操作,但是当成功登录时,所有数据都显示在我的登录页面上,但它不会显示图像,而是显示图像的名称。
<?php
// Connect to the database
require('config.php');
// Set username and password variables for this script
$user = mysql_real_escape_string($_POST["username"]);
$pass = mysql_real_escape_string($_POST["password"]);
// Make sure the username and password match, selecting all the client's
// data from the database if it does. Store the data into $clientdata
$clientdata = mysql_query("SELECT * FROM $tbl_name WHERE username='$user' and password='$pass'")
or die (mysql_error());
// Put the $clientdata query into an array we can work with
$data = mysql_fetch_array($clientdata, MYSQL_ASSOC);
// If the username and password matched, we should have one entry in our
// $clientdata array. If not, we should have 0. So, we can use a simple
// if/else statement
if(mysql_num_rows($clientdata) == 1){
$_SESSION['username'] = $user;
$_SESSION['firstname'] = $data['firstname'];
$_SESSION['lastname'] = $data['lastname'];
$_SESSION['address'] = $data['address'];
$_SESSION['nationality'] = $data['nationality'];
$_SESSION['id'] = $data['id'];
$_SESSION['photo']=$data['photo'];
?>
<?php
}else{echo "Click Login to try again or Register for an account.
Thank You";}
?>
我创建了一个 html 表,其中将放置图像,图像上传的文本字段是照片,图像目录是上传。
<tr>
<td bgcolor="#999999">Passport</td>
<td bgcolor="#FFFFFF"><p><?php echo "" . $_SESSION['photo'] . ""; ?></p></tr>