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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.