Jump to content

UserName and Password Issue


ZMike1

Recommended Posts

I'm working on a project that for whatever reason I cannot get the UserName and Password from one page to post to another.    It has to be something fairly easy that I'm missing

__________________________________

 

Here is the page with the submit button

 

__________

 

Here is a snip it of the other page where the submit button is

 

<?php if($_SESSION['CustomerID'] == 0) {

echo '<form method="post" action="index.php?menukey=4">

<div>

<span>UserName:</span><input type="text" class="text" maxlength="32" name="UserName" />

<span>Password:</span><input type="Password" class="text" maxlength="32" name="Password" />

<input type="submit" class="button" value="Login" /><br>

<span>New customer? </span><a href="index.php?menukey=2">Start here...</a>

</div>

</form>';

} else {

echo 'Customer ID = ' . $_SESSION['CustomerID'] . '<br>';

echo 'Welcome ' . $_SESSION['FirstName'] . '<br>';

echo 'Security ID: ' . $_SESSION['SecurityID'] . '<br>';

echo '<a href="index.php?menukey=44">Logoff</a>';

}

?>

 

______________________________________________________________________________

 

Here is the  log in page

 

 

 

 

 

 

 

<?php

 

$a = session_id();

if(empty($a)) session_start();

 

$CustomerID = 0;

$FirstName = "";

include "MySQLConnector.txt";

 

 

// Get the data from the form:

 

$UserName = (isset($_POST['UserName'])) ? $_POST['UserName'] : FALSE;

$Password = (isset($_POST['Password'])) ? $_POST['Password'] : FALSE;

 

//echo "Customer ID :  $CustomerID <br>";

//echo "FirstName :  $FirstName <br>";

//echo "UserName : $UserName <br>";

//echo "Password : $Password <br>";

 

 

$query="SELECT CustomerID, FirstName, SecurityID FROM Customers

WHERE UserName= '" . $UserName . "' AND Password= '" . $Password . "' "; // Build the query

$rs = @mysqli_query ($dbc, $query); // Return the Result Set

WHILE ($row = mysqli_fetch_array($rs, MYSQLI_ASSOC)) { // Fetch the data

    $CustomerID = $row['CustomerID'];

    $FirstName = $row['FirstName'];

    $SecurityID = $row['SecurityID'];

}

 

//echo "Here's the Query: $query <br>";

 

 

 

mysqli_query($dbc,$query);

 

if ($CustomerID!=0) {

$_SESSION['CustomerID'] = $CustomerID;

$_SESSION['FirstName'] = $FirstName;

$_SESSION['SecurityID'] = $SecurityID;

 

 

echo "FirstName: " . $_SESSION['FirstName'];

    } else {

echo "Student Not Found";

    }

 

mysqli_close($dbc);

 

//header("Location: index.php"); //Comment This Line to Debug

 

______________________________________________________________________________________

 

 

 

 

I have just about everything working.  I'm just not sure why my password when I hit submit isnt finding it.

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.