rishiraj Posted August 7, 2007 Share Posted August 7, 2007 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. Quote Link to comment Share on other sites More sharing options...
cjosephson Posted August 7, 2007 Share Posted August 7, 2007 Look up the session variable. It is designed to save usernames and passwords to be used across pages, until the user closes the browser or the script clears it out. http://www.tizag.com/phpT/phpsessions.php Quote Link to comment Share on other sites More sharing options...
rishiraj Posted August 8, 2007 Author Share Posted August 8, 2007 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.