Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I get my $_POST variables to post?
    text
    copied!<p>This is my first page, which would be my login page. The user types in their username, hits login, and then the broswer should take them to login.php Index.html</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Login&lt;/title&gt; &lt;/head&gt; &lt;body &gt; &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;h2 align=center&gt;Quiz Taker&lt;/h2&gt; &lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;p align=center&gt;&lt;/p&gt; &lt;br&gt; &lt;form method="post" action="login.php"&gt; &lt;table class="login" cellpadding=10 cellspacing=0 align="center" bgcolor="#cccccc" border="3"&gt; &lt;tr&gt; &lt;td&gt; &lt;input type="radio" name="userType" value="Student"/&gt; Student &lt;input type="radio" name="userType" value="Teacher"/&gt; Teacher &lt;td&gt; Username:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="username" size=10&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan=2 align="center"&gt; &lt;input type="submit" name="submit" value=" Log In "&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>When the user hits submit it will go to login.php which looks like this: </p> <pre><code>&lt;?php include_once("DatabaseConnection.php"); $stmt=$DBH-&gt;prepare("SELECT * FROM QuizUser where Name=?") $stmt-&gt;bindValue(1, $_POST['username']); $stmt-&gt;execute(); if ($row=$stmt-&gt;fetch()) { $ID=$row['ID']; } else { $stmt=$DBH-&gt;prepare("INSERT INTO QuizUser(Name) VALUES(?)") $stmt-&gt;bindValue(1, $_POST['username']); $stmt-&gt;execute(); $ID=$DBH-&gt;lastInsertId(); } $_SESSION['userID']= $ID; $_SESSION['userName']= $_POST['username']; $_SESSION['userType']=$_POST['userType']; if($_POST['userType'] == "Student") { header($string["Location:student.php"]); } else { header($string["Location:teacher.php"]); } ?&gt; </code></pre> <p>Which is not working and I cannot figure out why. It just pops up a parse error: syntax error, unexpected T_VARIABLE in ....myfile.... at line whever the first time I try and use the $_POST variable. By the way, I am starting my session in the DataBaseConnection.php that is imported at the top of login.php. </p>
 

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