I need to automatically set the ID column of a row in the database and I would like some help in figuring out how to do that, because at the moment I have to assign an ID through an input field.
PHP
<?php
//include db configuration file
include 'connection.php';
function user_joined($user_id, $user_name, $user_age, $user_end){
$user_id = mysql_real_escape_string(htmlentities($user_id));
$q = "INSERT INTO evenement (id, title, start, end) VALUES
('" . $user_id . "', '" . $user_name . "', '" . $user_age . "', '" . $user_end . "')";
mysql_query($q);
echo $user_id;
}
if(isset($_POST['user_id'], $_POST['user_name'], $_POST['user_age'], $_POST['user_end'], $_POST['action'])){
$user_id = $_POST['user_id'];
$user_name = $_POST['user_name'];
$user_age = $_POST['user_age'];
$user_end = $_POST['user_end'];
$action = $_POST['action'];
if ($action == 'joined'){
user_joined($user_id, $user_name, $user_age, $user_end);
}
}
?>
HTML form
<form class="form-inline">
<div id="d1" title="Maak afspraak aan" style="display: none">
<div class="control-group">
<label class="control-label">Gebruikers id:</label>
<div class="controls">
<input type="text" name="userid" placeholder="Gebruikers ID" id="id" />
</div>
</div>
<div class="control-group">
<label class="control-label">Title:</label>
<div class="controls">
<input type="text" name="username" placeholder="Titel" id="name" />
</div>
</div>
<div class="control-group">
<label class="control-label">Starttijd:</label>
<div class="controls">
<input type="text" name="userstart" placeholder="Starttijd" id="start" />
</div>
</div>
<div class="control-group">
<label class="control-label">Eindtijd:</label>
<div class="controls">
<input type="text" name="userend" placeholder="Eindtijd" id="end" />
</div>
</div>
</div>
</div>
</form>