<Form name="frm">
<center>
<Script Language="JavaScript">
<!--
//
function loadpage(){
var psj=0;
newwin = window.open(document.frm.pswd.value + ".htm")
}
//-->
</script>
Ingresa tu clave:
<input
type="password" name="pswd" size="20">
</center>
<center>
<p>
<input type="button" value="Entra"
onClick="loadpage()" name="button">
</p>
</center>
</form>
The code above is to have a page protected with a password.
Maybe you know how to use it.
If you do, please tell me how to use it, cause I need it.
If you do not know how to use the code above, please tell me a code that lets me use the password thing.
Thanx in advance
Manuel
It works, but you have to click the button, not hit Enter key.
When I click the button, it doesn´t work.
And where do I have to type the web page I want it to send you?
Please help me
Shockingly poor code. Absolutely shocking. That's a disgrace to the name code, it really is!
Try this instead:
| Code: |
<form method="post" action="pagename.php">
<center>
Ingresa tu clave:
<input type="password" name="pswd" size="20" /><br /><br />
<input type="submit" value="Entra" />
</center>
</form> |
Put the page's name instead of "pagename.php". It has to have the .php extension. So for the page you want to protect, if it is .html or .htm change it to .php. Now there's just a little bit of code you need to add to the top of the page, before anything else:
| Code: |
<?php
$correct_password = "correct password";
$no_password_message = "No password specified.";
$bad_password_message = "Incorrect password.";
if ($_POST['pswd'] != $correct_password && $_POST['pswd']) die ($bad_password_message);
elseif (!$_POST['pswd'])
{
session_start();
if ($_SESSION['pswd_'.__FILE__] != $correct_password)
die ($no_password_message);
}
else
{
session_start();
$_SESSION['pswd_'.__FILE__] = $correct_password;
}
?> |
Stick that on the top of every page you want to password protect. It'll accept users who've typed in the password, and anyone who has can continue to access the page until they close their browser without having to type the password in again. You'll have to change $correct_password to = whatever you want the right password to be, and you can also change the error messages by changing the next two lines.
Oh, you can only use this on a server that supports php. Frihost is one of them.
Thanx a lot, really 
Sorry for the double post but, I have just tried to use that code and the hosting site that my client wants does not support PHP
Can u still help me, guys?
How about:
| Code: |
<Form name="frm" action="javascript:loadpage()">
<center>
<Script Language="JavaScript">
<!--
//
function loadpage(){
var psj=0;
newwin = window.open(document.frm.pswd.value + ".htm")
}
//-->
</script>
Ingresa tu clave:
<input
type="password" name="pswd" size="20">
</center>
<center>
<p>
<input type="button" value="Entra" name="button">
</p>
</center>
</form>
|
With that code, where do I have to put the URL of the site I want to be protected with password, so when you type the password, the site loads up?