Jump to content

password protected pages


rishiraj

Recommended Posts

I want to create password protected pages where administrator can login and check details of request of products. I am currently using the following script.

 

<?php

// Define your username and password
$username = "username";
$password = "password";

if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {

?>

<h1>Login</h1>

<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <p><label for="txtUsername">Username:</label>
    <br /><input type="text" title="Enter your Username" name="txtUsername" /></p>

    <p><label for="txtpassword">Password:</label>
    <br /><input type="password" title="Enter your password" name="txtPassword" /></p>

    <p><input type="submit" name="Submit" value="Login" /></p>

</form>

<?php

}
else {

?>

<?php 
$con = mysql_connect("192.168.2.7", "dbname", "password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("indiamar_rishi", $con);

$result = mysql_query('SELECT * FROM `order` LIMIT 0, 30 ');

echo "<table border='1'>
<tr>
<th>Project Name</th>
<th>Project Description</th>
<th>Contact Person</th>
<th>Contact Email</th>
<th>Contact number</th>
<th>Company Name</th>
<th>Country</th>

</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['txtprojectname'] . "</td>";
  echo "<td>" . $row['txtdescription'] . "</td>";
echo "<td>" . $row['txtname'] . "</td>";
echo "<td>" . $row['txtemail'] . "</td>";
echo "<td>" . $row['txtphone1'] . "</td>";
echo "<td>" . $row['txtcompany'] . "</td>";
echo "<td>" . $row['txtcountry'] . "</td>";
  echo "</tr>";
  }

echo "</table>";

mysql_close($con);
?>

<?php

}

?> 

 

now i want to add extra features like admin can sort results by "submitted yesterday, last 7days, all time" first 50results, 50-100 results, back and next button"

 

I don't think all this is possible with this script cause it will ask for password again and again.

 

so please suggest any suitable script or logic that can help me.

I would prefer If I can display results with all features on same page.

I don't mind reading any topic or script related to this. I an newbie but I can edit the codes as per my requirement.

Link to comment
https://forums.phpfreaks.com/topic/63709-password-protected-pages/
Share on other sites

thanks cjosephson,

It really helped me.

 

I wanted to add features like admin can sort results by "submitted yesterday, last 7days, all time" first 50results, 50-100 results, back and next button"

I have made a form with calendar that can take the from and too date value and display data according to it.

How can i create button for next 50, previous 50, and links like

Page 1 2 3 4 5 6 7 8 9 10

 

What would be the best practice to do that?

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.