Dr-SeMSeM Posted June 24, 2009 Share Posted June 24, 2009 Hello everybody i wanna to ask about mini issuei want to create an index with domain name , once i open the page link asking me about user name and pass ( stored in page information or any other way )something like this pictureplease tell me how to create a page like this , once i type to true user and pass ... i can sea the content ..if now .. giving me access denied or worng user or pass ?thanks for help Link to comment Share on other sites More sharing options...
Ingolme Posted June 24, 2009 Share Posted June 24, 2009 That's not done with HTML. That has to do with configurations on the server. Link to comment Share on other sites More sharing options...
Dr-SeMSeM Posted June 24, 2009 Author Share Posted June 24, 2009 its only one user name and one password ... not multible useres .. only one user and one password .. i think it can be created using Java .. but what is the code if it can do it ..its about a name and password to view page only ... Link to comment Share on other sites More sharing options...
Ingolme Posted June 24, 2009 Share Posted June 24, 2009 Java on the server side, yes, it can be done. Or PHP. Have it clear: Java is not Javascript.However it won't show that box that's in your screenshot, you'd have to make an HTML form asking for the name and password and then check it on the server. Link to comment Share on other sites More sharing options...
Synook Posted June 25, 2009 Share Posted June 25, 2009 With a server-side language you can set HTTP 401 and send www-authenticate:basic to get the "native" authentication dialog like in the screenshot. Link to comment Share on other sites More sharing options...
Dr-SeMSeM Posted June 25, 2009 Author Share Posted June 25, 2009 one of my friends told me that its will be better to create it but as PHP page with config file where i canwrite the user and pass what i want to view content of this page ..if it possible with php page please tell me how to do it or give me the code because im not a programmer ..i just designer ...thanks for advance Link to comment Share on other sites More sharing options...
bOtskOOl Posted June 26, 2009 Share Posted June 26, 2009 Below is the code which will work for a single set of username and password. You can change username and password accordingly. Currently both the username as well as password is botskool. You need to create three files - login.php main.php logout.php Code for login.php - <?phpsession_start(); $errorMessage = '';if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) {if ($_POST['txtUserId'] === 'botskool' && $_POST['txtPassword'] === 'botskool') {$_SESSION['basic_is_logged_in'] = true;header('Location: main.php'); //give your own relative url hereexit;} else {$errorMessage = 'Sorry, wrong user Id / password';}}?><html><head><title>Basic Login</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head> <body><?phpif ($errorMessage != '') {?><p align="center"><strong><font color="#990000"><?php echo $errorMessage; ?></font></strong></p><?php}?> <form method="post" name="frmLogin" id="frmLogin"><table width="400" border="1" align="center" cellpadding="2" cellspacing="2"><tr><td width="150">User Id</td><td><input name="txtUserId" type="text" id="txtUserId"></td></tr><tr><td width="150">Password</td><td><input name="txtPassword" type="password" id="txtPassword"></td></tr><tr><td width="150"> </td><td><input type="submit" name="btnLogin" value="Login"></td></tr></table></form></body></html> Code for main.php - <?phpsession_start();if (!isset($_SESSION['basic_is_logged_in']) || $_SESSION['basic_is_logged_in'] !== true) { header('Location: login.php'); exit;}?><html><head><title>Main User Page</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><p>This is the area where you can place your content that is to be viewed. :-) </p><p> </p><p><a href="logout.php">Logout</a> </p></body></html> Change the content of main.php according to your needs.Code for logout.php- <?phpsession_start();if (isset($_SESSION['basic_is_logged_in'])){ unset($_SESSION['basic_is_logged_in']);}header('Location: login.php');?> Hope this helps Good luck! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.