Jump to content

Is there a way to change an image with text input?


PGTibs

Recommended Posts

I have a login page which contains an avatar image, however at this time i only shows the avatar of the last logged on contact. Is there a way for the image too be a default avatar until you enter the username into the login username is entered and it searches for the correct image and displays it?

 

index.php

<?php
session_start();
include 'config.php';

  $query = mysql_query("SELECT * FROM `staff`");

  while($result = mysql_fetch_array($query)) {

  $photo = $result["photo"];
?>
<!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=iso-8859-1" />
<title>Admin Panel :: Login</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 5px;
margin-right: 0px;
margin-bottom: 0px;
background: #F4CFFB;
}
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
}
.login {
position: absolute;
top: 20px;
left:350px;
width:320px;
height:256px;
background: #ffffff;
border-color: #000000;
border-width: 2px;
border-style: solid;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
}
.input:hover {
    border: 1px solid #f00;
    background: #ff6;
}
.input2:hover {
    border: 1px solid #f00;
    background: #FFC872;
}
-->
</style>

</head>

<body>
<div class="login">
<table width="315" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="315" height="10"></td>
  </tr>
  <tr>
    <td height="25"><table width="315" height="19" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="8"> </td>
        <td><div align="center"><span class="style1"><u>Login to the Admin Panel </u></span></div></td>
        <td width="9"> </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td width="315" height="4"></td>
  </tr>
  <tr>
    <td height="144" valign="top"><table width="315" height="144" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="3"></td>
        <td valign="top"><center>
	<?

  echo "<img style='border-width:1px; border-color:black; border-style:solid;' src='admin/$photo' height='80px' width='80px'>"; ?></center>
<?

echo "    

<form action='index.php?login=login' method='POST'><center>

<font size='1' face='Verdana'><b>Username:</b></font>

<br><input size='26' class='input' type='username' name='username_post' style='border-width:1px; border-color:black; border-style:solid; font-family: Verdana; font-size: 10px; color: #000000;'>";

echo "

</input>
          <br />
<font size='1' face='Verdana'><b>Password:</b></font>



	<font color='#FFFFFF' size='1' face='Verdana'> 

	<br><input type='password' class='input' name='password_post' size='26' style='border-width:1px; border-color:black; border-style:solid; font-family: Verdana; font-size: 10px; color: #000000;'></font><br><br>
	<input type='submit' class='input2' name='myclicker' value='Login' style='border-width:1px; border-color:black; border-style:solid; font-family: Verdana; font-weight: bold; font-size: 14px; color: #000000;'>
</center></form><br><br>";

	if($_GET['login'] == "login") {
$user1_post = addslashes($_POST["username_post"]);
$pass1_post = addslashes($_POST["password_post"]);
$pass1_post = md5($pass1_post);
if($user1_post == "" or $pass1_post == "") { echo "<b><font color='#FF0000' size='1' face='Verdana'> Error: You Did Not Enter A Password</b></font>"; exit; }
list($user) = mysql_fetch_array(mysql_query("SELECT `username` FROM `staff` WHERE username='$user1_post'"));
list($pass) = mysql_fetch_array(mysql_query("SELECT `password` FROM `staff` WHERE password='$pass1_post'"));
if($user1_post == "$user" and $pass1_post == "$pass") {
$sql = mysql_query("SELECT * FROM `staff` WHERE username='$user' AND password='$pass'");
if(mysql_num_rows($sql)!= 1) { exit; }
$result = mysql_fetch_array($sql);
$_SESSION['session_username'] = $result['username'];
$_SESSION['session_level'] = $result['level'];
$_SESSION['session_ip'] = $_SERVER['REMOTE_ADDR'];
echo "<meta http-equiv=\"refresh\" content=\"4;url=main.php\">";
echo "<font size='1' color='green' face='Verdana'>You Have Successfully Logged In... Please Wait...";
        exit;
} else { echo "<b><font color='#FF0000' size='1' face='Verdana'> Error: Your username and password didn't match</b></font>"; }
} 

?></td>
        <td width="4"></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td width="315" height="12"></td>
  </tr>
</table>
</div>
</body>
</html>
<?
			}
  mysql_close($ms);
  ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.