Jump to content

This code is not working


Guest Shohreh

Recommended Posts

Guest Shohreh

<!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

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

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

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

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

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 :blink: But still, great idea. :blink:Choco
Strange, 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

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

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...