Jump to content

Login help


Eoin

Recommended Posts

I am trying to create a login page where i am comparing a username and a password from two text boxes to a username and a password field from a database. I am having trouble getting the database variables to do the comparison with.

/////HTML///////////////////////////////////////////////////////////////////////////

User Name: <input id="UserBox" type="text" name="uname" /><br />

Password:  <input id="PassBox" type="password" name="pname" /><br />

<input id="theButton" type="button" class="roundedClass" value="Login" onClick="passCheck()" />

///////////////////////////////////////////////////////////////////////////////////////

<script type="text/javascript">

function passCheck()

{

var u = document.getElementById("UserBox");

var p = document.getElementById("PassBox");       

if (u.value == $username && p.value == $password)

{

window.location.href ='mainPage.html';

}

else alert("Invalid username or password.\nPlease try again .");

}

</script>

/////////////////////////////////////////////////////////

<?php

// Include file to Connnect to online database

include_once "mysql_connect.php";

// Collects data from  table

$data = mysql_query("SELECT * FROM login")

or die(mysql_error());

while($info = mysql_fetch_array( $data )){

  $username=$info['username'];

  $password=$info['password'];

}

?>

my question is how can i gain access to $username and $password so they can be used in the passCheck() function as they wont work as above?any help would be appreciated.

Eoin.

Link to comment
https://forums.phpfreaks.com/topic/262517-login-help/
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.