Guest Shohreh Posted August 3, 2006 Share Posted August 3, 2006 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><script language="JavaScript" type="text/JavaScript">var password;var pass1="sh95@hotmail.com"password=prompt('enter email','');if(password==pass1);{window.location("text.txt");}elsealert("no access");</script></body></html> Link to comment Share on other sites More sharing options...
Chandra.Vedantham@gmail.com Posted August 4, 2006 Share Posted August 4, 2006 Hi,Remove the ";" after the if(password==pass1) statement.It will work. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><script language="JavaScript" type="text/JavaScript"> var password; var pass1="sh95@hotmail.com" password=prompt('enter email',''); if(password==pass1){ window.location("text.txt"); } else alert("no access");</script></body></html>[code][/font] Link to comment Share on other sites More sharing options...
Golanlan Posted August 8, 2006 Share Posted August 8, 2006 I just must say- IT IS NOT SAFE TO USE THIS METHOD!After entering the wrong password, try to take a look at the source. It gives you the password itself. Do not use this method.I'll work on a safe method. Link to comment Share on other sites More sharing options...
Chocolate570 Posted August 8, 2006 Share Posted August 8, 2006 He's right. You should always use server side code or the htaccess file to password-protect a page/site. That way, the client can not just view the source to procure the password. Link to comment Share on other sites More sharing options...
Golanlan Posted August 8, 2006 Share Posted August 8, 2006 I've wrote a protected method for entering a page with a password COME ON IN!required:some_text.html with the following source: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>box?</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><script language="JavaScript" type="text/JavaScript">var password;password=prompt("Please enter your password")if (password!==""){window.location = (password + ".html")}elsealert("No way dude! :P");</script></body></html> and some_password.html in the same directory.On my page, the password is it_r0cks_my_s0cks Link to comment Share on other sites More sharing options...
Chocolate570 Posted August 8, 2006 Share Posted August 8, 2006 Hey, that's not a bad idea! I never thought o that. But the problem is most sites are accessible through anonymous FTP if run on ameteur servers, so it would be pretty easy to try out most of the files. Server side code is better But still, great idea. :)Choco Link to comment Share on other sites More sharing options...
Golanlan Posted August 8, 2006 Share Posted August 8, 2006 Hey, that's not a bad idea! I never thought o that. But the problem is most sites are accessible through anonymous FTP if run on ameteur servers, so it would be pretty easy to try out most of the files. Server side code is better But still, great idea. :blink:ChocoStrange, I've never saw a good free hosting server with an anonymous FTP.. If someone wants a safe method in a non-anonymus FTP server, this is the safest method of the easy ones :)anyways, Congrats on the 1,000 post Link to comment Share on other sites More sharing options...
Chocolate570 Posted August 9, 2006 Share Posted August 9, 2006 Thanks, I really didn't even notice O_OI've been on a couple that do, and I'm sure there are other ways to read files on a server. Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 9, 2006 Share Posted August 9, 2006 If someone really wants to safe password protect their site or some pages, they would use php or asp.Server-side languages may be more difficult than javascript, but php isn't actually so bad. If you know javascript, you'd also know php! If you really want safe security, you would choose for a language that hides its source at server location, processes it, and returns a clean html output to the client. Why would you even bother doing difficult things with javascript that might be able to get by? Link to comment Share on other sites More sharing options...
aspnetguy Posted August 9, 2006 Share Posted August 9, 2006 Actually the syntax for JavaScript and PHP only have small similarities...it is actually quite different especially once you look into the methods.Anyway I fail to see the point in you restating this point since it has been said already (about using a server-sid language and not javascript I mean). Link to comment Share on other sites More sharing options...
Chocolate570 Posted August 9, 2006 Share Posted August 9, 2006 Yup, they're both pretty much based on C, with javascript having SOME similarities with java. (KEYWORD SOME) Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 9, 2006 Share Posted August 9, 2006 Javascript works the same way as php does. Not the same, but similar. Both have objects, variables, arrays, etc, and most constructors and signs are the same. They both know what functions are, how to initiate them and how to call them, namely with brackets. Comments are the same. This is what I mean. I know that javascript has other functions than php has for the same thing, of course, it is another language. To set the type of a string to an integer, javascript uses Number(), where php uses settype() or gettype() to see what has been set. But the language construction is very similar. This would make it easy for people who are already used to javascript, and want to learn php too :)But the fact that I say this, is only my opinion, I don't claim it is easy to learn php or whatsoever. :)Maybe I shouldn't have said anything in the first place. Link to comment Share on other sites More sharing options...
Chocolate570 Posted August 9, 2006 Share Posted August 9, 2006 Javascript works the same way as php does. Not the same, but similar. Both have objects, variables, arrays, etc, and most constructors and signs are the same. They both know what functions are, how to initiate them and how to call them, namely with brackets. Comments are the same. This is what I mean. I know that javascript has other functions than php has for the same thing, of course, it is another language. To set the type of a string to an integer, javascript uses Number(), where php uses settype() or gettype() to see what has been set. But the language construction is very similar. This would make it easy for people who are already used to javascript, and want to learn php too But the fact that I say this, is only my opinion, I don't claim it is easy to learn php or whatsoever. Maybe I shouldn't have said anything in the first place.It's that way because both are based on C, like I said. Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 9, 2006 Share Posted August 9, 2006 I know, I reacted on aspnetguys response Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now