Jump to content

Password protection not working?


PGTibs

Recommended Posts

I have a webpage that, when you click a link it reveals more information about the clients. However, i want to make it so that you have to enter a password and if the password is correct to the client it shows the extra information.

However, currently the page is accepting the password but not showing the extra information. Wheres the problem?

 

<?php
session_start();
include 'config.php';
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>Error: You Did Not Enter A Password</b>"; exit; }
list($user) = mysql_fetch_array(mysql_query("SELECT `ID` FROM `clients` WHERE ID='$user1_post'"));
list($pass) = mysql_fetch_array(mysql_query("SELECT `password` FROM `clients` WHERE password='$pass1_post'"));
if($user1_post == "$user" and $pass1_post == "$pass") {
$sql = mysql_query("SELECT * FROM `clients` WHERE ID='$user' AND password='$pass'");
if(mysql_num_rows($sql)!= 1) { exit; }
$result = mysql_fetch_array($sql);
$_SESSION['session_username'] = $result['ID'];
$_SESSION['session_level'] = $result['level'];
$_SESSION['session_ip'] = $_SERVER['REMOTE_ADDR'];
echo "<meta http-equiv=\"refresh\" content=\"0;url=clients.php?action=edit$ID\">";
        exit;
} else { echo "<b>Error: Your username and password didn't match</b>"; }
} ?>


<head>
<style>
.submitbut {
position: absolute;
top: 20px;
left:350px;
}
</style>
</head>
<body>
<font face="verdana" size="1"><b><a href="addclients.php" target="content">Click Here To Add Clients</a> | <a href="removeclients.php" target="content">Click Here To Remove Clients</a>

<br><br>




<? 

  $query = mysql_query("SELECT * FROM `clients` ORDER BY `ID` DESC");

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

  $male = $result["ClientMale"];

   $female	   = $result["ClientFemale"];

    $agem = $result["ClientAgem"];

    $agef = $result["ClientAgef"];

	 $town = $result["ClientTown"];
	 $street = $result["ClientStreet"];
	 $post = $result["ClientPost"];

	 $num = $result["ClientNumber"];

	 $budget = $result["ClientBudget"];
	 $time = $result["ClientTime"];
	 $loc = $result["ClientLoc"];
	 $notes = $result["ClientNotes"];
	 $email = $result["ClientEmail"];

	 $ID = $result["ID"];

	 $action = $_GET["action"];

	  $budgetu = $_POST["budgetu"];
	  $timeu = $_POST["time2"];
	  $locu = $_POST["loc2"];
	  $notesu = $_POST["notes2"];


echo "<div class='info'><table width='100%' border='0' bgcolor='#ffccff' style='border-color: #000000; border-width: 1px; border-style: solid;'>

    <td colspan=2>

<form action='clients.php?login=login' method='POST'>
<B><font face=verdana size=1><u>(ID:<input size='1' type='username' name='username_post' value='$ID' style='font-family: Verdana; font-size: 10px; color: #000000;'>)
$male & $female</u>  &nbsp
<input type='password' name='password_post' size='14' style='font-family: Verdana; font-size: 10px; color: #000000;'>
<input type='submit' name='myclicker' style='font-size: 10px; font-family: verdana;' value='(More)'></form>

</td></td>



  <tr>

    <td colspan='2' valign='top'><font face=verdana size=1> <b>Male Age:</b> $agem<br>
 <b>Female Age:</b> $agef<br>

  </tr>

  <tr>

<td><font face=verdana size=1><b>Located At:</b> $town.<br>

  </tr>

</table></div>";

if($action == "edit$ID") {

echo "<div class='info' style='font-family: verdana; border-color: #000000; border-width: 1px; border-style: solid;'>

<b> <u>(ID:$ID) $male & $female</b></u><br>

<table cellspacing'0' cellborder='0' border='0' width='80%'>
<tr>
<td><font face=verdana size=1><b>Located At:<br></b> $street, $town, $post<br>
<B>Contact Number:</b> $num<br>
<B>Contact Email:</b> $email<br></color></td>
</tr>
<tr>
<td width='20%'>
<font face='verdana' size='1' style='text-decoration: underline;'>Budget:</td><td> $budget</td></tr><tr>
 <td width='20%'><font face='verdana' size='1' style='text-decoration: underline;'>Planned Wedding Time & Date:</td><td> $time</td></tr><tr>
 <td width='20%'><font face='verdana' size='1' style='text-decoration: underline;'>Planned Wedding Location:</td><td> $loc</td></tr><tr>
 <td width='20%' valign='top'><div style='word-break:normal;word-wrap:break-word;'><font face='verdana' size='1' style='text-decoration: underline;'>Notes:</font><br></td>

<td width='60%'><font face='verdana' size='1'>$notes
</font></div></td></tr></table></font>
<br>
<div align='right'><font face='verdana' size='1' style='text-decoration: underline;'><a href='clients.php' target='content'>(Hide)</a><br><a href='clientedit.php?action=edit$ID' target='content'>(Edit)</a></div></font></div>
</div>"

;

}
			}
  mysql_close($ms);

  ?>

Link to comment
https://forums.phpfreaks.com/topic/144243-password-protection-not-working/
Share on other sites

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.