Chciałbym dodać płeć do bazy danych i nie mam pojęcia jak to napisać. Wydaje mi się ze to trzeba zrobić ifem.
i przy okazji czy ten kod jest w miarę bezpieczny?
<?php
require_once"dbconect.php";
$conn = mysqli_connect($host, $db_user, $db_password,$db_name);
// Check connection
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
if (isset($_POST['name']) && isset($_POST['surname']) && isset($_POST['city']) && isset($_POST['Dateofbirth']) && isset($_POST['street']) && isset($_POST['number'])&& isset($_POST['zipcode']) && isset($_POST['phone']) && isset($_POST['email']) ){
$name = trim(strip_tags($_POST['name']));
$surname = trim(strip_tags($_POST['surname']));
$city = trim(strip_tags($_POST['city']));
$sex = trim(strip_tags($_POST['sex']));
$Dateofbirth = trim(strip_tags($_POST['Dateofbirth']));
$street = trim(strip_tags($_POST['street']));
$number = trim(strip_tags($_POST['number']));
$zipcode = trim(strip_tags($_POST['zipcode']));
$phone = trim(strip_tags($_POST['phone']));
$email = trim(strip_tags($_POST['email']));
}
else{
echo 'nie isinieja';
}
$sql = "INSERT INTO tab (name,surname,city,Dateofbirth,street,number,zipcode,phone,email) values ('$name','$surname','$city','$Dateofbirth','$street','$number','$zipcode','$phone','$email')";
if ($conn->multi_query($sql) === TRUE) {
echo "New records created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
mysqli_close($conn);
?>
Oto mój kod
Bardzo dziękuję za każda radę :)