Ive been trying all day to create a new entry in my table. Sorry for all the text in spanish. I hope it is not a problem.
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$nueva_tienda = $_POST['nueva_tienda'];
if(!empty($nueva_tienda)){
echo "not empty";
include('connection.php');
mysqli_query($dbc, "INSERT INTO tiendas (nombre) VALUES ('$nueva_tienda')");
}
else{
echo "Porfavor llena todos los campos";
}
}
else{
echo "No form has been submitted";
}
?>
<h1>Nueva tienda</h1>
<form action="processing2.php" method="post">
<p>Nombre de la nueva tienda: <input type="text" name="nueva_tienda" maxlength="50"/></p>
<p><input type="submit" name="submit" value="Submit"/></p>
</form>
EDIT:
Added connection include file from comments:
<?php $hostname = "localhost";
$username = "root";
$password1 = "";
$dbname = "inventario_collares"; //making the connection to mysql
$dbc = mysqli_connect($hostname, $username, $password1, $dbname) OR die("could not connect to database, ERROR: ".mysqli_connect_error());
//set encoding
mysqli_set_charset($dbc, "utf8");
?>