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.

Link to comment
Share on other sites

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");
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.