I need advice to use radio buttons in html to query into MYSQL base on the user selection.
The table is called "Trainers"
There are Three trainers:
The user choose what trainer he/she want to setup a meeting with. On the MYSQL I want to show the "krillavilla" got "5" meetings with users and "Urie" got "0" meetings with users.
I research this post: How can i add radio buttons record into MySQL fields using PHP but I was trying to avoid arrays
And on this post: Inserting the selection of radio buttons into MySQL
Doesnt answer my question what I am looking for.
This is my php:
<?php
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
$link = mysqli_connect("localhost","******","******","*****");//This is the login creditial
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());//Error check for execution
}
// Escape user inputs for security
$trainers = mysqli_real_escape_string($link, $_POST['trainers']);
// attempt insert query execution
$sql = "INSERT INTO trainers (trainers) VALUES ('$trainers')";
if(mysqli_query($link, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// close connection
mysqli_close($link);
?>
This is my html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add Record Form</title>
</head>
<body>
<form action="test2.php" method="post">
<p>
<input type="radio" name="trainers" id="krillavilla">krillavilla
</p>
<p>
<input type="radio" name="trainers" id="Urie">Urie
</p>
<p>
<input type="radio" name="trainers" id="Novac">Novac
</p>
<input type="submit" value="Submit">
</form>
</body>us
</html>
This is my second form page. I am trying to create a GYM schedule using three form webpages where the user will:
Sign up a membership=> User Select the trainer=> User selected what type of membership he/she wants=> confirmation page
but for now i need help of figuring out how can i get my radio buttons data to record how many users that assign to trainer on MYSQL.
BTW I used this:
http://www.tutorialrepublic.com/php-tutorial/php-mysql-insert-query.php
as my guide
value="Urie"
而不是id="Urie"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.