There is a form:
<!doctype html> <html lang="ru"> <head> <meta charset="UTF-8"> <title>Countries</title> </head> <body> <form action="getForm.php" method="POST"> <label for="country">Введите страну</label> <input type="text" name="country" size="15"><br> <label for="city">Введите город</label> <input type="text" name="city" size="15"><br> <label for="district">Введите район</label> <input type="text" name="district" size="15"> <br> <input type="submit" value="Добавить в базу"> </form> </body> </html> There is a handler:
<?php $country=$_POST['country']; $city=$_POST['city']; $district=$_POST['district']; $link = mysql_connect("localhost", "root") or die("Could not connect: " . mysql_error()); mysql_select_db("countries"); mysql_query("SET NAMES UTF8"); mysql_query("SET CHARACTER SET UTF8"); $s="INSERT INTO Country VALUES ('".$country."','".$city."','".$district."');"; mysql_query($s); if($s){ echo "Запись добавлена"; } else { mysql_error(); } mysql_close($link); ?> As it is already clear, I want the data entered in the form to be inscribed in the database. When checking the echo function is executed, but nothing is written to the database, I break my head ...
Here is the base itself:
+---------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+-------------+------+-----+---------+----------------+ | id | int(10) | NO | PRI | NULL | auto_increment | | name_country | varchar(20) | NO | | NULL | | | name_city | varchar(20) | NO | | NULL | | | name_district | varchar(20) | NO | | NULL | | +---------------+-------------+------+-----+---------+----------------+ Help me to understand :(