Jump to content

[SOLVED] asking the user


HAN!

Recommended Posts

Well, if you mean a pop-up box, the htaccess/htpasswd combo would do very nicely.

 

If you mean a form, simply create an html form, link it to a php document that checks the passwords and administrative access against your (database, im assuming) and either give them access or not.

Well....you have different mehthods  i-e http user authentication method and form method.

Here's the form method.

 

You have to make a login form in html :

 

login.html:

 

user name :

password :

 

in the form action tag, specify your authentication file for e.g <form action="authen.php">

 

authen.php:

 

include "connection.php";
$tb_name = "administrators";
$query = "SELECT * FROM $tb_name where name='$_POST[users]' and password='$_POST[password]'";
$result = mysql_query($query, $conn) or die(mysql_error()."Can't Process Query");
if (!mysql_num_rows($result)){ 
echo "Record Doesn't Exist"; 
}
else {
echo "Congratulations you are authenticated<br>";
        }

 

where connection.php file contains your connection to mysql and database like:

 

connection.php

<?
$conn = @mysql_connect("localhost","your_username","your_password") or die(mysql_error()."Cannont Connect to Database");
$dbname = "mydatabase";
$db = mysql_select_db($dbname, $conn) or die (mysql_error()."Cannot Select Database");
?>

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.