I try make php login but i get this error: Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given,
what I do wrong?
register.php
Use this way instead of your way.
addslashes(trim($_POST['username']));
pass $connect
as your first parameter in mysqli_real_escape_string
for this first make connection then do rest.read here http://php.net/manual/en/mysqli.real-escape-string.php
If you use the procedural style, you have to provide both a connection and a string:
$name = mysqli_real_escape_string($conn, $name);
Only the object oriented version can be done with just a string:
$name = $link->real_escape_string($name);
The documentation should hopefully make this clear.
The following works perfectly:-
if(isset($_POST['signup'])){
$username=mysqli_real_escape_string($connect,$_POST['username']);
$email=mysqli_real_escape_string($connect,$_POST['email']);
$pass1=mysqli_real_escape_string($connect,$_POST['pass1']);
$pass2=mysqli_real_escape_string($connect,$_POST['pass2']);
Now, the $connect is my variable containing my connection to the database. You only left out the connection variable. Include it and it shall work perfectly.
There is slight change in mysql_real_escape_string mysqli_real_escape_string. below syntax
mysql_real_escape_string syntax will be mysql_real_escape_string($_POST['sample_var'])
mysqli_real_escape_string syntax will be mysqli_real_escape_string($conn,$_POST['sample_var'])