Hello, I need some help. My problem: I working on a form to submit a registration user. Everything works but I’m trying to pass the name of the user type and insert it into a table called users together with he user type ID. I’m able to get the ID into the table but I’m not sure how to get the user type as well. I’m learning php so be patient with me :).
FORM
<p>User Type: <select name="type_id">
<?php
foreach ($types as $type)
{
echo "<option value=\"" . $type['user_type_id']. "\">" . $type['type_name'] . "</option>\n";
}
?>
</select></p>
<p>First Name: <input type="normal" class="form-control" placeholder="Your first name" required autofocus name="first_name" maxlength="40" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" /></p>
<p>Last Name: <input type="normal" class="form-control" placeholder="Your last name" required name="last_name" maxlength="40" value="<?php if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>" /></p>
<p>Email Address: <input type="normal" class="form-control" placeholder="Email address" required name="email" maxlength="80" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /> </p>
<p>Password: <input type="password" class="form-control" placeholder="Password" required name="pass1" maxlength="20" /></p>
<p>Confirm Password: <input type="password" class="form-control" placeholder="Password" required name="pass2" maxlength="20" /></p>
<p><button type="submit" name="submit" class="btn btn-sm btn-primary" />Register</button></p>
<input type="hidden" name="submitted" value="TRUE" />
PHP
$t = ($_POST[‘type_id’]);
// Register the user in the database...
// Make the query: newMsgCount
$q = "INSERT INTO users (user_type_id, first_name, last_name, email, pass, registration_date) VALUES ('$t','$fn', '$ln', '$e', SHA1('$p'), NOW())";
$r = @mysqli_query ($dbc, $q); // Run the query.
if ($r) { // If it ran OK.
// Print a message:
echo '<h1>Thank you!</h1>
<p>You are now registered!</p><p><br /></p>';