My issue is that I am making a dating site form with following categories
firstname,lastname,username,password,email,mysex,yoursex,relationship,date of birth, and country
I did the whole php code so when submitted would send info to sql server. But there is some error on php half, date of birth(DOB) day,month,year. And mysex and yoursex values are not submitting. Sql gives undefined index. Here is my code.(The falf that is not submitting)
<form action="process.php" method="post" id="register" class="col-xs-12">
<input class="register-switch-input" type="radio" name="mysex" value="hombre" id="me-male" > <label class="register-switch-label" for="me-male"> Hombre </label>
<input class="register-switch-input" type="radio" name="mysex" value="mujer" id="me-female"> <label class="register-switch-label" for="me-female"> Mujer </label> <br>
<input type="radio" name="yoursex" value="hombre" id="your-male" checked> <label for="your-male"> Hombre </label>
<input type="radio" name="yoursex" value="mujer" id="your-female"> <label for="your-female"> Mujer </label>
<input type="radio" name="yoursex" value="cualquiera" id="cualquiera"> <label for="cualquiera">Cualquiera </label> <br>
<label class="form-label">Nacimiento:</label>
<select name="DOBMonth" >
<option> - Month - </option>
<option value="January">January</option>
<option value="Febuary">Febuary</option>
""
<select name="DOBDay" >
<option> - Day - </option>
""
<select name="DOBYear">
<option> - Year - </option>
<option value="2003">2003</option>
The "" is because the selects have a million options and are unnessecary. Here is my php code
<?php
$servername = "localhost";
$username = "diego966";
$password = "ddddd966";
$dbname= "signup";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$firstname = $_POST["firstname"];
$lastname = $_POST["lastname"];
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$mysex = $_POST["mysex"];
$yoursex = $_POST["yoursex"];
$relationship = $_POST['relationship'];
$DOBday = $_POST['DOBday'];
$DOBmonth = $_POST['DOBmonth'];
$DOByear = $_POST['DOByear'];
$country = $_POST['country'];
$sql="INSERT INTO accounts(firstname, lastname, username, password, email, mysex, yoursex, relationship, DOBday, DOBmonth, DOByear, country)
VALUES ('$firstname', '$lastname','$username', '$password', '$email','$mysex', '$yoursex', '$relationship', 'DOBday', 'DOBmonth ','DOByear', '$country')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
$DOBday = $_POST['DOBday'];should be$DOBday = $_POST['DOBDay'];- notice the capital on D for day. M for month. Y for year in yourPOSTAlso for radio buttons your error is probably because the returned value for$yoursexis an array