I'am tryng to show a message after you pressed submit with information.
1. This name allready exists, use another
or
2. The name is added!
html
<form action="add.php" method="post">
<input type="text" name="name" id="name" class="form-control" required>
<input class="btn btn-default" type="submit" value="Submit">
</form>
php
$connectie=mysqli_connect("localhost","usernam","pw","db");
$name = $_POST['name'];
$name = stripslashes($name);
$name = mysql_real_escape_string($name);
$check_if_exists="SELECT * FROM names WHERE name = '$name'";
if($data[0] > 1) {
echo"already exists";
} else {
$newUser="INSERT INTO users (name) values('$name')";
if (mysqli_query($connectie,$newUser))
{
echo "name is registerd";
}
else
{
echo "error<br/>";
}
Right now it post the echo on add.php, not on the page where the form is. How do I get it there?