Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, I would avoid the variable variables, they're really not necessary in this context and they make for a moving target if you're not sure what keys are actually reaching that script, and they're bad practice due to the security issues that they create. Instead, I would put the escaped values within settings.php into an array. Then you can simply var_dump() the array after including settings.php, and see what was available.</p> <pre><code>function extract_requests(){ $res = array(); foreach ($_REQUEST as $key =&gt; $value) { if($key){ $res[$key] = $value; } } return $res; } </code></pre> <p>Second, manually call login.php with the correct url string, exactly what you would want the javascript to call for, so that you can be sure that any behavioral problems aren't coming from the login.php script itself.</p> <p><code>http://localhost/somewhere/login.php?uid=50</code></p> <pre><code>include("../../settings.php"); $input = extract_requests(); var_dump($input); echo $input['uid']; echo $_POST['uid']; </code></pre> <p>Finally, I would check your data that you are sending in post(). I'm not a javascript guru, but </p> <pre><code>uid:uid, pwd:pwd </code></pre> <p>looks like it would cause issues to me, so it'd be good to make sure that your data is being sent in the way that you expect.</p> <pre><code>$(document).ready(function(){ $(".index_login_subm").click(function(){ uid = $("input:username").val(); pwd = $("input:password").val(); var inputData = {uid:uid, pwd:pwd}; alert(uid+" "+pwd); // If you have a console.log() available, just use it on inputData here instead. $.post("backend/login.php",inputData ,function(data){ alert("Returned data: " + data); }); return false; }); }); </code></pre> <p>Edit: Based on the mysql_real_escape_string-only-when-a-connection-has-been-initiated thing, I've removed the escaping from the code above, because really, you'll be better off escaping the stuff right before you put it into the sql.</p> <p>In addition, keep in mind that using javascript for the login <strong>WILL</strong> come back to bite you, with functionality as basic and necessary as login, you don't want a javascript error to break any ability for a viewer to log in. Here it will do so.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload