0
Well, I’m starting my studies in php and mysql, and I’m having a hard time doing something theoretically simple, which would be a form that sends the information provided to a local db. By pressing send, nothing happens, db table remains intact. Thank you in advance for the time you have to help me
<?php
session_start();
$mysqli = new mysqli('localhost', 'root', '', 'dbteste');
if($_SERVER['REQUEST_METHOD'] == 'POST'){
if($_POST['password'] == $_POST['confirmpassword']){
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password']; //md5 hash passwor security
$sql = "INSERT INTO user (username, password, email) VALUES($username, $password, $email)";
$mysqli->query($sql);
}
}
?>
<h1>Register</h1>
<form class="form" action="create-account.php" method="post" enctype="multipart/form-data" autocomplete="off">
<input type="text" name="username" value="" placeholder="username" required/>
<input type="password" name="password" value="" placeholder="password" required/>
<input type="password" name="confirmpassword" value="" placeholder="confirm password" required/>
<input type="text" name="email" value="" placeholder="e-mail" required/>
<input type="submit" name="createacount" value="create acount">
</form>
These variavies:
$username, $password, $email
must be in single quotes... '$username', '$password', '$email' If Voce der echo nesse $sql and run the query on a client like Heidi and Workbench, they will show you the error that is giving– Bruno Folle