• 0

HTML Password Form


Question

EDIT: Problem solved, thanks Hackersoft MS MVP.

EDIT 2: Problem was only solved locally. See this post.

I'm having trouble with a Javascript pop up box not appearing on Internet Explorer. I have tested it with IE7 and IE8 with no success. It works on Firefox 3.6.3 and Opera.

On internet explorer this yellow bar appears;

282fhqr.png

However, once clicked and given temporary permission the page reloads not showing the pop up box and the yellow bar is still present.

I have re-created the situation here;

http://html.comuf.com/

problem.html is the page I need help on. The correct password is real which redirects you to real.html.

I am open to using new scripts but this line/function is crucial;

location.href= password + ".html";

This problem is for a friend of mine who does design work, his client is having trouble with this.

Link to comment
Share on other sites

Recommended Posts

  • 0

Dont forget to add some sort of security so no-one else can just type in a random page and see other peoples information (ive done that before :whistle: ) look up session for that i think =)

Link to comment
Share on other sites

  • 0

Dont forget to add some sort of security so no-one else can just type in a random page and see other peoples information (ive done that before :whistle: ) look up session for that i think =)

Please explain?

Link to comment
Share on other sites

  • 0

I think he means a log in system.

Correct.

From my understanding every user is being given a password and that password is also the name of the page so if i had two users one with boom and other with bump as there page and password and one decided to just type in the other just for fun in the address bar they could see someone elses page. Of cause this depends on how the passwords and pages are going to be generated when there created! Even so its best to have some sort of security in place so this isn't possible im guessing sessions would be the best option but im no php guru and dont know if there are better ways to check a password + page name + session id maybe someone can help there :unsure:

Link to comment
Share on other sites

  • 0

That and flexibility.

For example, we only redirect/include the file if its found:

<?php
if($_POST['submit']) {
	//Search for all HTML files in the folder and store it in an array
	$files = glob("*.html");

	//Get the filename from the form and add the .html extension.
	$filename = $_POST['pass'].".html";

	//Check if there are matches
	if(in_array($filename, $files)) {
		//Send a user to the HTML file
		header("Location: ".$filename);

		// Or include it
		//include $filename;
	}
	else {
		//Nothing
		echo '404';
	}
}
?>
<form method="post" action="">
	Please Enter Your Password:
	<input type="password" name="pass" value="" />
	<input type="submit" name="submit" value="Go!" />
</form>

This looks like your solution here, especially since it lets you customize your own error message if an invalid password is typed.

Link to comment
Share on other sites

  • 0

This looks like your solution here, especially since it lets you customize your own error message if an invalid password is typed.

It only has 1 problem! It's requiring me to enter the password twice. I'd like to play it off as the second is simply confirming the password, but I'm afraid the company the guy I am helping is doing this for will not appreciate that.

The Code I am using

red.php

<?php
if($_POST['submit']) {
        //Search for all HTML files in the folder and store it in an array
        $files = glob("*.html");

        //Get the filename from the form and add the .html extension.
        $filename = $_POST['pass'].".html";

        //Check if there are matches
        if(in_array($filename, $files)) {
                //Send a user to the HTML file
                header("Location: ".$filename);

                // Or include it
                //include $filename;
        }
        else {
                //Nothing
                echo 'Incorrect Password. Please Try Again.';
        }
}
?>
<form method="post" action="">
        Please Enter Your Password:
        <input type="password" name="pass" value="" />
        <input type="submit" name="submit" value="Go!" />
</form>

blue.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Company Name</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head> 

<body>
<form name="input" action="red.php" method="get">
Please Enter Your Password:
<input type="password" name="user" />
<input type="submit" value="Submit" />
</form> 


</body>
</html>

I also hope this is my last question regarding this specific project :angry:

Link to comment
Share on other sites

  • 0

It only has 1 problem! It's requiring me to enter the password twice. I'd like to play it off as the second is simply confirming the password, but I'm afraid the company the guy I am helping is doing this for will not appreciate that.

The Code I am using

red.php

<?php
if($_POST['submit']) {
        //Search for all HTML files in the folder and store it in an array
        $files = glob("*.html");

        //Get the filename from the form and add the .html extension.
        $filename = $_POST['pass'].".html";

        //Check if there are matches
        if(in_array($filename, $files)) {
                //Send a user to the HTML file
                header("Location: ".$filename);

                // Or include it
                //include $filename;
        }
        else {
                //Nothing
                echo 'Incorrect Password. Please Try Again.';
        }
}
?>
<form method="post" action="">
        Please Enter Your Password:
        <input type="password" name="pass" value="" />
        <input type="submit" name="submit" value="Go!" />
</form>

blue.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Company Name</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head> 

<body>
<form name="input" action="red.php" method="get">
Please Enter Your Password:
<input type="password" name="user" />
<input type="submit" value="Submit" />
</form> 


</body>
</html>

I also hope this is my last question regarding this specific project :angry:

You don't need a form in blue.html, it's already in the php file above.

  • Like 1
Link to comment
Share on other sites

  • 0

You don't need a form in blue.html, it's already in the php file above.

I swear I tried that but it didn't work. Doesn't matter, works now! So the HTML file is not needed at all? Is it possible to add a centered image above the password input box? Also when enter is pressed, instead of clicking the button the page refreshes, small fix?

I really appreciate this. Let me know if I can click some ads on anyone's website who has helped me or something.

Link to comment
Share on other sites

  • 0

I swear I tried that but it didn't work. Doesn't matter, works now! So the HTML file is not needed at all? Is it possible to add a centered image above the password input box? Also when enter is pressed, instead of clicking the button the page refreshes, small fix?

I really appreciate this. Let me know if I can click some ads on anyone's website who has helped me or something.

Well, the first file is php/html combo file. Put the image after the php section and before the form. In blue.html, put whatever you want your customer to see when they log in with "blue."

Link to comment
Share on other sites

  • 0

I swear I tried that but it didn't work. Doesn't matter, works now! So the HTML file is not needed at all? Is it possible to add a centered image above the password input box? Also when enter is pressed, instead of clicking the button the page refreshes, small fix?

I really appreciate this. Let me know if I can click some ads on anyone's website who has helped me or something.

Now you're talking about Ajax. Honestly, leave it simple. You don't seem to know much on this so no sense in rushing into what you're not sure of. I'd highly recommend that you start researching what has been said to you already in this thread. While it's nice to have people help you to get things going ultimately this is your responsibility and not anyone else's.

For a centered image, have you bothered to look that up on your own yet?

http://www.w3.org/Style/Examples/007/center

Link to comment
Share on other sites

  • 0

Now you're talking about Ajax. Honestly, leave it simple. You don't seem to know much on this so no sense in rushing into what you're not sure of. I'd highly recommend that you start researching what has been said to you already in this thread. While it's nice to have people help you to get things going ultimately this is your responsibility and not anyone else's.

For a centered image, have you bothered to look that up on your own yet?

http://www.w3.org/Style/Examples/007/center

I am aware how to enter a centered image as well as any other basic HTML task. I was not aware however that HTMl could be added into a PHP file with the .php extension. As I said earlier on this has stimulated my interest and I will begin to read up starting with HTML again once I finish this fairly urgent task. I have the XHTML/CSS/XML thread bookmarked as well as many other tutorials. I understand what you are trying to say but ultimately it is just adding unnecessary replies to this thread. I am as frustrated and eager to leave this thread to die as you are. Maybe another noob will come across this and it will prevent him from asking such questions.

SNIPPED. SEE BELOW.

Link to comment
Share on other sites

  • 0

The format of an image is dependent on your page's doctype http://www.w3schools.com/tags/tag_DOCTYPE.asp

http://www.w3.org/TR/html4/struct/objects.html#edef-IMG / http://www.w3schools.com/tags/tag_IMG.asp

HTML4

 <center> <img src="urlhere.jpg" alt="img here"> </center>

XHTML

 <img src="urlhere.jpg" alt="url here" />

Also, the following snippet is entirely HTML: http://www.w3schools.com/html/html_forms.asp

 <img src="https://i50.tinypic.com/2j3o76u.png" />
<form method="post" action="">
        Please Enter Your Password:
        <input type="password" name="pass" value="" />
        <input type="submit" name="submit" value="Submit" />
</center>
                </form>

A file can end in .php and contain PHP and HTML.

http://php.net/index.php

Link to comment
Share on other sites

  • 0

Turns out i was because I haven't solved the enter problem. When I enter the password and hit enter, the page refreshes and doesn't redirect to the password + .html. Google could not help me. Any ideas?

Link to comment
Share on other sites

  • 0

Turns out i was because I haven't solved the enter problem. When I enter the password and hit enter, the page refreshes and doesn't redirect to the password + .html. Google could not help me. Any ideas?

I'm confused, are you using the code I posted earlier?

Link to comment
Share on other sites

  • 0

I'm confused, are you using the code I posted earlier?

Yes, with a few changes that possibly could have broken it if you believe yours would have solved this.

<?php
if($_POST['submit']) {
        //Search for all HTML files in the folder and store it in an array
        $files = glob("*.html");

        //Get the filename from the form and add the .html extension.
        $filename = $_POST['pass'].".html";

        //Check if there are matches
        if(in_array($filename, $files)) {
                //Send a user to the HTML file
                header("Location: ".$filename);

                // Or include it
                //include $filename;
        }
        else {
                //Nothing
                echo 'Incorrect Password. Please Try Again.';
        }
}
?>

<head>
<title>TITLE</title>
<body>
<img src="bar.jpg" "align="middle" />
<form method="post" action="">
        Please Enter Your Password:
        <input type="password" name="pass" value="" />
        <input type="submit" name="submit" value="Submit" />

		</form>
</body>

Link to comment
Share on other sites

  • 0

Yes, with a few changes that possibly could have broken it if you believe yours would have solved this.

<?php
if($_POST['submit']) {
 //Search for all HTML files in the folder and store it in an array
 $files = glob("*.html");

 //Get the filename from the form and add the .html extension.
 $filename = $_POST['pass'].".html";

 //Check if there are matches
 if(in_array($filename, $files)) {
 //Send a user to the HTML file
 header("Location: ".$filename);

 // Or include it
 //include $filename;
 }
 else {
 //Nothing
 echo 'Incorrect Password. Please Try Again.';
 }
}
?>

<head>
<title>TITLE</title>
<body>
<img src="bar.jpg" "align="middle" />
<form method="post" action="">
 Please Enter Your Password:
 <input type="password" name="pass" value="" />
 <input type="submit" name="submit" value="Submit" />

		</form>
</body>

Works fine here.

Link to comment
Share on other sites

  • 0

All has been solved with exception to having the browser submit when the enter key is pressed in IE. It will do .

This was the code used (HUGE thanks to iHazCool)

<?php
if($_POST['submit']) {
        //Search for all HTML files in the folder and store it in an array
        $files = glob("*.html");

        //Get the filename from the form and add the .html extension.
        $filename = $_POST['pass'].".html";

        //Check if there are matches
        if(in_array($filename, $files)) {
        //Send a user to the HTML file
        header("Location: ".$filename);

        // Or include it
        //include $filename;
        }
        else {
        //Nothing
        echo 'Incorrect Password. Please Try Again.';
        }
}
?>
<html>
<head>
<title>TITLE</title>
<body>
<p style="text-align: center;"><img src="logo.jpg" alt="img" /></p>
<div align="center"> 
<form method="post" action="">
        <p style="text-align: center;"><i>Please enter your password and <b>click submit.</b></i></p><br />
        		<br />
				Password:
        <input type="password" name="pass" value="" />
        <input type="submit" name="submit" value="Submit" />
</form>
</div>
</body>
</html>

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.