Error or not and insert to database mysql
- by Azzyh
Why wont this work?
<?php include "top.php";
include "connect.php";
if(isset($_POST["submit"])) {
$error = "";
if(empty($_POST["name"])) {
$error .= "Du glömde märket!<br>";
if(empty($_POST["rating"])){
$error .= "Du glömde att bedömma märket!<br>";
if(empty($_POST["worth"])){
$error .= "Du glömde att välja vilken klass den hör till!<br>";
if(empty($_POST["username"])){
$error .= "Du glömde att skriva ditt namn!<br>";
if(empty($_POST["rating"])){
$error .= "Du glömde att skriva någonting?!!<br>";
}}}}}
if(!empty($error)){
echo $error;
}else{
$name = $_POST["name"];
$rating = $_POST["rating"];
$worth = $_POST["worth"];
$favorite = $_POST["favorite"];
$username = $_POST["username"];
$description = $_POST["description"];
mysql_query("INSERT INTO brands (name, rating, worth, favorite, username, description) VALUES ('$name', '$rating', '$worth', '$favorite', '$username', '$description')");
echo "<span style='color: green'>Yir yir, <a href='brand.php'>klicka här för att gå till Märken.</a></span>";
}
}
It doesnt come with errors it just say the succeed message like it has inserted to database