HAN! Posted October 18, 2007 Share Posted October 18, 2007 how to ask the user for entering a username and password to verify if he is administrative or user for permitting him to continue? Thanks Link to comment https://forums.phpfreaks.com/topic/73776-solved-asking-the-user/ Share on other sites More sharing options...
kratsg Posted October 18, 2007 Share Posted October 18, 2007 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 https://forums.phpfreaks.com/topic/73776-solved-asking-the-user/#findComment-372243 Share on other sites More sharing options...
ashrafzia Posted October 18, 2007 Share Posted October 18, 2007 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 https://forums.phpfreaks.com/topic/73776-solved-asking-the-user/#findComment-372245 Share on other sites More sharing options...
HAN! Posted October 19, 2007 Author Share Posted October 19, 2007 well that was a lot of help thanks Link to comment https://forums.phpfreaks.com/topic/73776-solved-asking-the-user/#findComment-372992 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.