Jump to content

Is this secure?


Sparticuz

Recommended Posts

I'm writing a simple password protected file. The catch is that I only want one php file and I wanted to know if this is secure. If $thepassword is commented out it should skip the password and go straight to the content. Would it be better to somehow encrypt the password using md5?

 

$thepassword = "pwgoeshere";

if(!$password && $thepassword != null){
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
echo "<head><title>Please enter your password</title>\n";
echo "<link href=\"$css\" rel=\"stylesheet\" type=\"text/css\" />\n";
echo "</head>\n<body>\n";
echo "<form method=\"post\" id=\"pwform\" action=\"".$_SERVER["PHP_SELF"]."\">\n";
echo "<p><input type=\"password\" name=\"password\" id=\"password\" /></p></form>\n";
echo "</body></html>";

die();
}

if($password == $thepassword || $thepassword == null) {

Secure content

} else {
//The wrong password was entered or something wrong happened.
//This will forward you back to the password entry page.
header("Location: ".$_SERVER['PHP_SELF']."");
}

Link to comment
https://forums.phpfreaks.com/topic/62906-is-this-secure/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.