I have a problem with the php file below.When I click Send button, it shows a new window that says that the connection is ok and informations added to the database, but when I check the database, neither name nor email have been added. Will you please help me out to understand what's the problem?
<html>
<body>
<?php
$name = filter_input(INPUT_POST, 'name');
$email = filter_input(INPUT_POST, 'email');
    $servername = "127.0.0.1";
    $username = "username";
    $password = "password";
    $dbname = "Subscription";
    $con = mysql_connect($servername,$username,$password,$dbname);
    if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
    echo "Connected successfully";
    mysql_select_db("Subscription", $con);
    $name = false;
    if (isset($_POST['name'])) { $name = $_POST['name'];
    $email = false;
    if (isset($_POST['email'])) { $name = $_POST['email'];
 }
}
    echo "'You have been successfully added.' . '<br>'; ";
mysql_close($con)
?>
</body>
</html>
this is the code I used after the suggested corrections:
$con = mysql_connect($servername,$username,$password,$dbname);
    if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
    echo "Connected successfully";
      mysql_select_db("Subscription", $con);
    $sql =  
$sql = "INSERT INTO newsletter (name, email) VALUES ('".mysql_real_escape_string($_POST['name'])."','".mysql_real_escape_string($_POST['email'])."');";
         if (!mysql_query($sql,$con))
          {
          die('Error: ' . mysql_error());
          }
        echo "'You have been successfully added.' . '<br>'; "
mysql_close($con);
?>
it gives me this error now: Parse error: syntax error, unexpected 'mysql_close' (T_STRING), expecting ',' or ';' in /opt/lampp/htdocs/project/Newsletter-signup.php on line 38.
Thanks for your help Costantin, my head is exploding.
