我需要帮助您了解如何在用户登录后更改图片。'因为我正在创建一个在线广播电台,我希望我的听众能够查看DJ的当前在线状态,基于该图像的空气。该图像存储在一个php页面(djonair.php)中,该页面内的图像(djonair.php)将在用户登录后更改,然后使用iframe在主页面(index.html)中调用该页面。我使用iframe来调用该页面,因为我的主页是一个HTML页面(index.html)。如何根据登录人的身份更改图片
,这里是我的login.php代码:
<?
session_start();
if(session_is_registered(myusername)){
header("location:djmain.php");
}
?>
<font face="calibri" color="white" size="6">: DJ Log In :</font><br>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#005180">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="password" id="mypassword"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
这里是我的checklogin.php代码:
<?php
$host="sqlhostname"; // Host name
$username="sqlusername"; // Mysql username
$password="sqkpassword"; // Mysql password
$db_name="dbname"; // Database name
$tbl_name="tablename"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection
$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);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:djmain.php");
}
else {
echo "Wrong Username or Password";
echo '<br>Go back to <a href="login.php">log-in</a> page.';
}
?>
你有没有试图做到这一点? – Bruce