html - php register script not adding to mysql database


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">
    <title> Exercise 3</title>
    <meta charset="utf-8">
        $name = “Frank”;
        $age = “28”;

        echo "<br>";

        echo "<br>";

        echo "<br>";



There are lot of things you need to change:

  • I am assuming that your connecting to your database twice i.econfig.php and by usingmysql_connect.

  • Your website is highly vulnerable to SQL injection. So usemysqli_real_escape_string or some other functions to prevent from such attacks.

  • In the below query:

Change this:

    $taken=("SELECT * FROM employee WHERE username ='{$myusername}'");

Remove those brackets like this:

    $taken="SELECT * FROM employee WHERE username ='{$myusername}'";
  • Start usingmysqli orPDO asmysql is being deprecated.

People are also looking for solutions to the problem: How to pass javascript variable to php inside javascript function


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.