PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $con = $mysqli; $con->query("create table users(username varchar(255), email varchar(255), password varchar(255))"); $_REQUEST['username'] = 'foo'; $_REQUEST['email'] = 'bar'; $_REQUEST['password'] = 'baz'; $username = stripslashes($_REQUEST['username']); //escapes special characters in a string $username = mysqli_real_escape_string($con, $username); $email = stripslashes($_REQUEST['email']); $email = mysqli_real_escape_string($con, $email); $password = stripslashes($_REQUEST['password']); $password = mysqli_real_escape_string($con, $password); $query = "INSERT into `users` (username, email, password) VALUES ('$username', '$email', '" . md5($password) . "')"; $result = mysqli_query($con, $query); echo json_encode($con->query("select * from users")->fetch_assoc()), "\n"; $username = stripslashes($_REQUEST['username']); // removes backslashes $username = mysqli_real_escape_string($con, $username); $password = stripslashes($_REQUEST['password']); $password = mysqli_real_escape_string($con, $password); // Check user is exist in the database $query = "SELECT * FROM `users` WHERE username='$username' AND password='" . md5($password) . "'"; $result = mysqli_query($con, $query) or die(mysqli_error($con)); $rows = mysqli_num_rows($result); var_dump($rows);
Show:  
Copy Clear