(а он плох) и насколько его можно уменьшить.
<?php
require_once 'connectionToDB.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>MySQL test</title>
</head>
<body>
<form method="post">
<input type="text" name="country_name" minlength="3" maxlength="64" placeholder="Enter country name">
<input type="number" name="country_zip" min="1" max="999999999" placeholder="Enter zip code">
<input type="number" name="country_population" min="1" max="999999999" placeholder="Enter population">
<input type="submit" name="submit">
</form>
</body>
</html>
<?php
if (isset($_POST['country_name'],$_POST['country_zip'],$_POST['country_population']) &&
!empty($_POST['country_name'] && $_POST['country_zip'] && $_POST['country_population'])){
$coutryname=$_POST['country_name'];
$countryzip=$_POST['country_zip'];
$countrypopulation=$_POST['country_population'];
require_once 'connectionToDB.php';
$link1 = mysqli_connect($host, $user, $password, $database);
if ($link1->connect_error) {
die("Connection failed: " . $link1->connect_error);
}
$dbinsert="INSERT INTO information (CountryID, CountryName, CountryZip, CountryPopulation)
VALUES (NULL, '$coutryname', '$countryzip', '$countrypopulation')";
if ($link1->query($dbinsert) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $dbinsert . "<br>" . $link1->error;
}
$link1->close();
}
include 'ShowDatabaseText.php';
он плох полностью
Обсуждают сегодня