hello,
i'm very dull at js, so i hope you guys can help me.
ok, i have create a prompt box that will ask user to enter a password, and this prompt box will take user to secured page.

<script type="text/javascript">
function show_prompt()
{
var name=prompt("Please enter your password","Fill Here");
if (name!=null && name!="")
  {
  location.href="index.php";
  
  }
}


</script>

so, how to create a variable that can take password from mysql using js?

if (password=="password in database")<< how to call password from database?
{
   location.href="index.php";
}

i hope you guys can help me. appreciate it so much.

You can use AJAX technology for checking password, but if js says it is correct, don't forget to check it with PHP (server side), we cannot trust javascript.

Easiest way to get data for me is use http://api.jquery.com/jQuery.post/

You could send the password to the PHP, PHP checks the database and if correct then echoes secret content.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.