PHP Programming > General PHP Help

What's wrong with this query?

<< < (4/9) > >>

traydavid:
I hear you.  And thanks.  I guess that's the problem.  Where do I get the admin's info and how to hold it for the query?  Never thought of that.

Here is the html login form:


--- Code: ---<h2><br>Store Web Site Administration<br></h2>

<p>Please log in below</p>

<form action="smallvalidate.php" method="post">

<b>User Name:</b><br>

<input type="text" size="20" name="userid"><br>

<br>

<b>Password:</b><br><input type="password" size="20" name="password">

<br><br>

<input type="submit" value="smalllogin">

</form>
--- End code ---

And here is the validate php code:


--- PHP Code: ---<?php
session_start();
include ("../mylibrary/smalllogin.php");
login();

$userid = $_POST['userid'];
$password = $_POST['password'];

$query = "SELECT userid, name from admins where userid = '$userid' and password = ('$password')";
$result = mysql_query($query);

if (mysql_num_rows($result) == 0)
{
   echo "<h2>Sorry, your account was not validated.</h2><br>\n";
   echo "<a href=\"smalladmin.php\">Try again</a><br>\n";
} else
{
   $_SESSION['store_smalladmin'] = $userid;
   header("Location: smalladmin.php");
}
?>

--- End code ---


The other code we have been discussing is on the page that the admin would be referred to when he logs in successfully, called smalladmin.php

Thanks.

ErnieAlex:
Well, you store the userid in a variable:     $_SESSION['store_smalladmin'] = $userid;
This gives you the session variable that is available on any page that starts with session_start();
So, assuming that this USERID is what your admin id is, you would change your first query from
where adminid=adminid";   to where adminid=" . $_SESSION['store_smalladmin'];

(Remember to make sure your first line of PHP code is session_start();  )

Try that and let me know...  It's midnight here and I am crashing soon...  Not sure how much longer I will be awake...   Good luck...

traydavid:
Thank you.  Have a good one. 

ErnieAlex:
You too, make sure you let me know if that works...  Then we can sort out the rest tomorrow...  Nite!

traydavid:
Busy day.  Late posting...

Seems to 'want to work' but I'm getting that same error that the code was expecting a boolean response.  I can't see anything that would cause that.  Thanks.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version