Script for Viewing a PHP Order Form?

  • Thread starter Thread starter Bre
  • Start date Start date
B

Bre

Guest
I am working on a dynamic website and I have to create a script that will enable only certain people to view submitted orders. Any ideas on how to do this? I haven't used PHP much before.
 
I'm not going to write an entire script for orders, but I will show you how to make a simple authorization form. There are a few ways to do it, the best way is using a database but no need if your site is small. The other way is to use a .htaccess file in apache - here is the PHP-only way:

Save the following script as login.php:
<?php

$user = "test";
$pass = "cat";

if (isset($_POST['user']) AND isset($_POST['pass'])) {
if ($user!=$_POST['user'] OR $pass!=$_POST['pass']) {
die("Sorry, this page requires authorization to view.");
}
}
else {

?>
<form action="login.php" method="POST">
<b>User</b>:<input type="text" name="user"><br>
<b>Pass</b>:<input type="password" name="pass">**<input type="submit" value="Go">
</form>
<?php
die();
}

?>

Everything below this is what you want your logged in user to see.

----------------------------------------------------------------------------------------
// this is the end of the script do not include this or anything below

This script does not use cookies, so if you want them to stay logged in you have to add cookie support. There are also many sites with free login scripts such as hotscripts.com, but if you only need to hide 1 page this is sufficient.
 
I'm not going to write an entire script for orders, but I will show you how to make a simple authorization form. There are a few ways to do it, the best way is using a database but no need if your site is small. The other way is to use a .htaccess file in apache - here is the PHP-only way:

Save the following script as login.php:
<?php

$user = "test";
$pass = "cat";

if (isset($_POST['user']) AND isset($_POST['pass'])) {
if ($user!=$_POST['user'] OR $pass!=$_POST['pass']) {
die("Sorry, this page requires authorization to view.");
}
}
else {

?>
<form action="login.php" method="POST">
<b>User</b>:<input type="text" name="user"><br>
<b>Pass</b>:<input type="password" name="pass">**<input type="submit" value="Go">
</form>
<?php
die();
}

?>

Everything below this is what you want your logged in user to see.

----------------------------------------------------------------------------------------
// this is the end of the script do not include this or anything below

This script does not use cookies, so if you want them to stay logged in you have to add cookie support. There are also many sites with free login scripts such as hotscripts.com, but if you only need to hide 1 page this is sufficient.
 
Back
Top