I want to insert values into my database. I have phpMyAdmin database on a free webserver. Here is the code:
$con = mysqli_connect("hostname", "user", "password", "databasename");
$name = $_POST["name"];
$username = $_POST["username"];
$password = $_POST["password"];
$email = $_POST["email"];
$phonenumber = $_POST["phonenumber"];
$statement = mysqli_prepare($con, "INSERT INTO User (name, username, password, email, phonenumber)
VALUES (?, ?, ?, ?, ?)");
mysqli_stmt_bind_param($statement, "sss", $name, $username, $password, $email, $phonenumber);
mysqli_stmt_execute($statement);
mysqli_stmt_close($statement);
mysqli_close($con);
And the problem is how in phpMyAdmin I could insert values like "... VALUES ('Caroline', 'CC'...");and it worked, and i can insert with the code above like "... VALUES ('?', '?', '?'..."); but it inserts ? into every column.
Here is the table with Values( '$name', '? ', '?'..)
:
So how could I insert $name with ' ' and bind param? If i change in bind_param the $name into '$name' it still doesn't work. But if I change VALUES('$name') then it insert the right value into the table.