View Full Version : Password Box to redirect same page
natex2 12-03-2005, 10:21 PM Now a few threads below I asked how to make a password box where when the correct password is entered you are redirected to a different page. But now I wanted to know how to make a password box where when the correct password is written you stay at the same page.
Here is what I tried to write but when I tested it out and went to the webpage that had the password, I entered it correctly but the password box would just keep showing up again and again:
<script>
var ans="password here"
var pass=prompt("What is the password?")
if(pass == ans)
{
window.location="http://samewebpage"
}
else
{
window.location="http://differentwebpagehere"
}
</script>
kittycat 12-03-2005, 10:44 PM You have to have the password script on a separate page. If you keep it on the same one, it will keep showing the password box because it's always going to be at the beginning of that page, and the code is going to want to run each time you reload.
natex2 12-03-2005, 10:48 PM You have to have the password script on a separate page. If you keep it on the same one, it will keep showing the password box because it's always going to be at the beginning of that page, and the code is going to want to run each time you reload.
Yeah but I do want it on the same page. I could put it on a different page but I want it on the same page :rant: :cool:
putnamehere 12-03-2005, 11:06 PM heres a php script
<?php
$pass = $_POST['password'];
$password = "ans";
if ( $pass == $password )
{
exit();
} else {
header("Location: http://www.samepage.com/");
}
?>
just make a forum and name the input password and the action name.php and put that code in name.php
natex2 12-03-2005, 11:11 PM I dont want this on a forum! Its going on a freewebs website!:mad: :rant: :help: :grouch:
J-man91 12-04-2005, 12:05 AM I think he meant the word "form" instead of "forum".:)
natex2 12-04-2005, 12:07 AM I think he meant the word "form" instead of "forum".:)
No you are so wrong. :rolleyes: :duh: :lolol: He said forum and he was talking about phpBB.
starlet 12-04-2005, 12:27 AM PHP not phpbb...he did mean form.
putnamehere 12-04-2005, 12:34 AM ye i ment form and php.. anyway you could always put that script on a host that surports php and then link the 'Form' to it?
natex2 12-04-2005, 12:49 AM nope doesnt work. i put it in and it appears blank, freewebs must not support php. here is a script i have been trying to use, the pass and username are nate:
<script>
//Encrypted Password script- By Rob Heslop
//Script featured on Dynamic Drive
//Visit http://www.dynamicdrive.com
function submitentry(){
password = document.password1.password2.value.toLowerCase()
username = document.password1.username2.value.toLowerCase()
passcode = 1
usercode = 1
for(i = 0; i < password.length; i++) {
passcode *= password.charCodeAt(i);
}
for(x = 0; x < username.length; x++) {
usercode *= username.charCodeAt(x);
}
//CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
if(usercode==125009720&&passcode==125009720)
//CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
{
window.location=gameforum.24ex.com}
else{
alert("password/username combination wrong")}
}
</script>
<form name="password1">
<strong>Enter username: </strong>
<input type="text" name="username2" size="15">
<br>
<strong>Enter password: </strong>
<input type="password" name="password2" size="15">
<input type="button" value="Submit" onClick="submitentry()">
</form>
But when I test it, nothing happens, and at the bottom of the browser it says "error on page". Can you tell me whats wrong with this? I got this script at http://www.dynamicdrive.com/dynamicindex9/password.htm and I changed it around abit so the password would be simple.
putnamehere 12-04-2005, 01:01 AM what i ment was put that code on a host that surports php.
eg you register ur username '123456' with t35.com you name a file with the php code above in it, pass.php and upload it the your account... you then go to your freewebs site and use this code...
<FORM ACTION="http://www.123456.t35.com/pass.php " METHOD="POST" NAME="pass">
Password:<br>
<INPUT TYPE="password" SIZE="30" maxlenght=20 NAME="password"><BR>
<INPUT TYPE="submit" NAME="submit" VALUE="Go!">
</FORM>
natex2 12-04-2005, 01:05 AM no intiendo
harmor 12-04-2005, 01:15 AM <script>
var ans="harmor"
function pass()
{
var pass=prompt("What is the password?")
if(pass == ans)
{
document.getElementById('secret_info').innerHTML = "This is the secret info that only logged in user will see";
}
else
{
window.location="http://differentwebpagehere"
}
}
</script>
<input type="button" value="Sign In" onClick="pass()" />
<div id="secret_info"></div>
harmor 12-04-2005, 01:31 AM If a moderator comes along can you join this post with the one above it?
If you want me to explain what is happening I'll gladly tell you.
I just don't want to be a waste of my time.
natex2 12-04-2005, 01:51 AM Thanks, that was somewhat useful. And it works, but I still want to know how to do the thing i asked before
natex2 12-04-2005, 02:34 AM Nevermind I Found It! It Was On This Site Already Haha!
|