I am trying to get a custom query working using a mysql statement prepared as a string before being called:
$sql_select_query = “select * from data WHERE owner = ‘”.$login.”‘;”;
$g->select_command = $sql_select_query;
This returns no results. The error message shows that gridphp thinks the $login variable is empty. This cannot be true. I tested the contents of the $login variable by echoing out before hand, and it exists, but the error message shows nothing between the two single quotes: ”
Any guess what’s going on here?
Thanks.
Sorry, some more information… I am using the auth.php page you provided for authentication. So I am trying to use the $login variable that the user logged in with as part of the query, to return results owned by that user.
How is this possible? 35 if (isset($login)) { 36 echo $login; 37 } else { 38 echo \”Not set: \”.$login; 39 exit(1); 40 } This simultaneously returns the login text AND falls through the else to echo \”Not set: \”
It’s because grid is loaded with 2 calls. Perhaps you need login variable in session and then use it from session.
POST variables are only available on first call, where ajax call don’t send POST again.
Ref: https://www.gridphp.com/docs/misc-faqs/#q-how-to-load-grid-based-on-_post-data-from-other-page
Beside above link, I think easy way is to save login variable in session after successful login and then use it in your query (without using POST)
Thank you Abu, that\’s helpful.
So do you recommend starting the Session variable in the auth.php file or in my index.php file?
I need to set Session_start() in which file? How can I ensure that the next user doesn\’t use the same Session? Do I need to close the Session in the logout area of auth.php?
Thanks in advance.
I did a Dession_start in my index file and set the Session variable in auth.php and it works, thanks.