html - php register script not adding to mysql database
813
Just wondering what I'm doing wrong here guys. This is my register screen, I'm using an older version of php as im following a tutorial. The script so far detects missing fields and existing usernames, however when I try to register new user it doesnt add to the mysql database ?
<!DOCTYPE html>
<html lang="en">
<head>
<title> Exercise 3</title>
<meta charset="utf-8">
</head>
<body>
<?php
$name = “Frank”;
$age = “28”;
var_dump($name);
echo "<br>";
print_r($name);
echo "<br>";
var_dump($age);
echo "<br>";
?>
</body>
</html>
Answer
Solution:
There are lot of things you need to change:
I am assuming that your connecting to your database twice i.e
config.php
and by usingmysql_connect
.Your website is highly vulnerable to SQL injection. So use
mysqli_real_escape_string
or some other functions to prevent from such attacks.In the below query:
Change this:
Remove those brackets like this:
mysqli
orPDO
asmysql
is being deprecated.