Hey guys I have been pulling my hair out trying to figure out why this php code isnt working. Basically I have the database and tables all set up correctly and I am trying to get the data filled in by the user to go to the mysql database.
I have been googling the problem for hours and have yet to find a solution. When I click submit on the page the page refreshes and looks like the data has submitted but nothing appears when I query the DB.
<form action="#" method="post">
<div class="row">
<h4>Select your school</h4>
<p>If you can't find it, contact your administrator about signing your school up!</p>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
Choose your school from the dropdown menu
<span class="caret"></span>
</button>
<select title="Select your School" name="School" id="schools">
<option value="1">University of Central Florida</option>
<option value="2">Seminole State College</option>
<option value="3">School of Hard Knocks</option>
</select>
</div>
</div>
<div class="row">
<h4>Name</h4>
<input class="form-group col-lg-4" id="first" name="first" type="text" placeholder="First">
<input class="form-group col-lg-4" id="last" name="last" type="text" placeholder="Last">
</div>
<div class="row">
<h4>Email Address</h4>
<input class="form-group col-lg-8" id="email" name="email" type="text" placeholder="ex. Flava.Flav@netscape.com">
</div>
<div class="row">
<h4>Password</h4>
<input class="form-group col-lg-8" id="password" name="password" type="text" placeholder="ex. Hunter2">
</div>
<div class="row">
<input id="submit" name="submit" type="submit" value="submit" class="btn btn-primary">
</div>
</form>
</div> <!-- /container -->
<?php
error_reporting(E_ALL);
if (isset($_POST['submit']))
{
$firstName = -1;
$lastName = -1;
$email = -1;
$password = -1;
$school = -1;
$dropdown_val = -1;
$connect=mysqli_connect('localhost','root','yanni123','eventmanager');
if(mysqli_connect_errno($connect))
{
echo 'Failed to connect';
}
$firstName = $_POST["first"];
$lastName = $_POST["last"];
$email = $_POST["email"];
$password = $_POST["password"];
$dropdown_val = $_POST["School"];
mysqli_query($connect, "INSERT INTO users (idusers, firstName, lastName, password, emailAddress, school)
VALUES (1, '$firstName', '$lastName', '$password', '$email', '$dropdown_val')");
mysqli_close($connect);
}
?>