Unable to retrieve student info from MySQL database using PHP _POST on form input
<p>I'm making a simple web app wherein in one of my database tables has two columns, ID and User.</p>

<p>In one file I have a form where I input a name. I then want receive input from the form using _POST and then query the database to retrieve that name's (student's) info and join with data from other tables. </p>

<p>The problem is I always get zero results from the database. However, if I modify the code to _POST the student's ID, then I get results from the database. So, I can't figure out why it doesn't work if I use the form to enter the name rather than ID.</p>

<p>Here is my form:</p>

<pre><code> echo '&lt;form name="postStudent" action="studentListCourses.php" method="post"&gt;';

    echo 'Name:&lt;br&gt;
        &lt;input type="text" name="student"&gt;';

    echo '&lt;input type="submit" value="save"/&gt;';

echo '&lt;/form&gt;';
</code></pre>

<p>And then on the studentListCourses file I use:</p>

<pre><code>$student = $_POST['student'];
    // $student = (string)$student;
    echo $student; 
    echo '&lt;br&gt;';

    // Query DB for selected student
    $Tusers_SQLselect = "SELECT * FROM users WHERE users.User='".$student."';"; 
</code></pre>

<p>But I always get zero results from the database. If I change the last clause in the query to:</p>

<pre><code>WHERE users.ID='".$student."';";
</code></pre>

<p>then I get the result back from my query, assuming I type in a valid ID in my form. Why can't I get result by typing in a valid name in the form?</p>