Jump to content


Photo

can NOT get query to pull data based on WHERE clause


  • Please log in to reply
21 replies to this topic

#21 Stooney

Stooney
  • Members
  • PipPipPip
  • Advanced Member
  • 1,093 posts
  • LocationLas Cruces, NM

Posted 14 October 2006 - 06:08 PM

ignore my post lol, crayon's > mine

<embed src='.wav' autostart='true' loop='false'
width='2' height='0'>
</embed>
i found that ERMMMMM thats called PHP!!!!


#22 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 14 October 2006 - 06:33 PM

Ok, it's good to stop and clarify. You're pretty much on track with your assessment of what i've got working so far:

okay you seem to have 3 different scripts going here: your form, your target, and some other script called members.  And it seems that your form script's action targets your target script, but you are trying to access your form's posted variables in some other script called members.php .  My best guess is that you have a login form that asks for the username/password, and then a script to authenticate it, and then upon authentication, you get whisked away to another script called members.php and you are wanting to do another query based on the same information.  Is that even remotely right?


login.php:
Basic login form
Contains the session_start();
Form action = $PHP_SELF so it parses to itself instead of external script
Checks username/password against the database to validate existence
Forwards the person onto 'members.php' page via header() statement in IF no errors occur
Passes the username variable 'username' via session or, at least I think it does

members.php:
- continues session/validates existence of session
- posts $username variable as $username='$_POST['username'] which, now I understand, will not post to this page since it's not the page parsing the data
- runs mysql query to pull the data regarding that member with WHERE clause being $username
- Displays various data from the database throughout the page

So, basically it's two pages/scripts. The login.php contains the parsing script. The members.php page (the 'target page' after login) contains code for extracting the data to display.

The breakdown appears to be in passing the form value(s) 'username' to the members.php page so the query:

$sql = "SELECT * FROM plateau_pros WHERE username='$username'";
$result = mysql_query($sql, $conn) or die(mysql_error());

can pull the required data. Right now after logging in the 'members.php' page is completely blank which means it's not passing that variable.

Now, not to confuse anything at this point, but i'd love to use the 'memberid' as the primary variable passed in order to utilize that in a variety of ways since it's always a unique number. So, passing that would be preferred. I was using 'username' since it was a form field that I felt would be passed in the $_POST method. By using the memberid field instead I can create url's pointing like:

referrals.php?memberid=$memberid


Make sense?

Also, did I say THANKS FOR THE HELP? :)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users