I am having trouble with this code. I want to add a row into the table via a HTML form. Here is the code:
EDIT: Here is the HTML code of the form:
<form role = "form" action = "aanmaken.php" method = "post" class = "col-lg-4 col-lg-offset-1 col-md-8 col-sm-12">
<div class="form-group">
<label for "eventName">Naam event: </label>
<input id = "eventName" class = "form-control" type = "text" name = "eventName" placeholder = "Hier typen">
</div>
<div class="form-group">
<label for "date">Datum: </label>
<input id = "date" class = "form-control" type = "text" name = "date" placeholder="YYYY-MM-DD">
</div>
<div class="form-group">
<label for "time">Tijd: </label>
<input id = "time" class = "form-control" type = "text" name = "time" maxlength="5" placeholder="18:00">
</div>
<div class="form-group">
<label for "max_spelers">Max spelers: </label>
<input id = "max_spelers" class = "form-control" type = "number" name = "max_spelers" maxlength="2" placeholder="Hier typen">
</div>
<input id = "submit" type="submit" value="Aanmaken">
</form>
And the PHP:
include 'connect.php';
$eventName = $_POST['eventName'];
$date = $_POST['date'];
$time = $_POST['time'];
$aantal_spelers = $_POST['max_spelers'];
$addEvent = "INSERT INTO `dbi286018`.`dutch_delight` (`id`, `eventName`, `date`, `time`, `aantal_spelers`, `current_spelers`) VALUES (NULL, $eventName, $date, $time, $aantal_spelers, \'0\');";
if ($conn->query($addEvent) === TRUE) {
echo "Je hebt een evenement aangemaakt! Vraag op het forum of op xbox live of mensen je evenement willen bijwonen.";
}
else {
echo "Er ging iets fout tijdens het aanmaken van je evenement... probeer het later nog eens, of neem contact op met een van de leiders.";
mysql_error();
}
I keep getting the else statement. Is there something I am doing wrong?
Thanks!
$conncreated inconnect.php??mysql_error()?!? Are you using MySQL? or MySQLi or PDO?dbi286018.dutch_delight(id,eventName,date,time,aantal_spelers,current_spelers) VALUES (NULL, '$eventName', '$date', '$time', '$aantal_spelers', '0');";