-1
This is my first post here, I’ve been following the forum for a long time but I never wanted to interact, today this desire arose along with a little problem ...
I’m learning to html, css, php
and etc... from tutorials, after numerous failures I end up achieving what I want. I have the habit of watching several tutorials about the same time and after watching all decide which to use, based on the divergence of information between them and my intuition. Until it works, but something always goes wrong and then I start looking for content to solve. One of the problems that haunts me is that I don’t know how to cite the mistake happened, like this one that’s happening now. So I think here would be the best option.
The problem: `
<?php </br>
session_start();</br>
$_SESSION['message'] = '';
$mysqli = new mysqli('localhost','root','','accounts'); </br>
if ($_SERVER['REQUEST_METHOD'] == 'POST') { <br>
if ($_POST['password'] == $_POST['confirmpassword']){ <br>
$username = $mysqli->real_escape_string($_POST['username']); <br>
$email = $mysqli->real_escape_string($_POST['email']); <br>
$password = md5($_POST['password']);
$sql = "INSERT INTO users (username, email, password) "
. "VALUES ('$username', '$email', '$password')";
//if the query
if ($mysqli->query($sql) === true) {
$_SESSION['message'] = "deu certo";
header("location: welcome.php");
}
else {
$_SESSION['message'] = "Usuario nao pode ser add";
}
}
}
?>
Hard to understand that code tag, my God.
This is the table I created: but when I go to check the db only has this:
This is my first question, if I did something wrong please tell me. Thank you!
Post the form that brings the values, because this is a problem in it, not in Insert. Print the variable on the screen
$sql
, see if the values are really coming to her. Need to go doing tests to see where the problem is.– rbz