0

im a learning HTML, PHP and mysql and i have been following a few tutorials as i learn by doing not by researching. I have an issue with the website i have followed the tutorial to the end and no matter how many times i go through i cannot find a single issue, error reporting doesnt show any errors either.

ill give you the code however i dont want someone to fix my mistake and send the code back, I would much rarther someone point out where my mistake is and explain my mistake for me to fix. Thank you in advance.

<?php
error_reporting(E_ALL);
define('DB_HOST', 'localhost');
define('DB_NAME', 'website');
define('DB_USER', 'root');
define('DB_PASSWORD', '');

$con = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

if (isset($_POST['Register'])) {
    if (!empty($_POST['Email'])) {
        $query = mysqli_prepare($con, "SELECT * FROM users WHERE Email =    ?");
        mysqli_stmt_bind_param($query, "s", $_POST['Email']);
        mysqli_stmt_execute($query);
        mysqli_stmt_store_result($query);
        if(mysqli_stmt_num_rows($query) != 0)
        {
            echo "SORRY...YOU ARE ALREADY REGISTERED USER...";
        }
        else
        {
            $query = mysqli_prepare($con, "INSERT INTO user (First_Name,Last_Name,Email,Password) VALUES ($First_Name, $Last_Name, $Email, $Password)");
            mysqli_stmt_bind_param($query, "ssss", $_POST['First_Name'], $_POST['Last_Name'], $_POST['Email'], $_POST['Password']);
            mysqli_stmt_execute($query);
            echo "REGISTRATION SUCCESSFUL";
        }
    }
}
?>

<!doctype html>
<html>
<head>
<link href="CSS/master.css" rel="stylesheet" type="text/css" />
<link href="CSS/menu.css" rel="stylesheet" type="text/css" />
<meta charset="utf-8">
<title>Adult Gaming Underground</title>
</head>

<body>
<div class="Container">
    <div class='Header'></div>
    <div class="Menu"
        <ul id="nav">
            <li><a href="#">Home</a></li>
            <li><a class="hsubs" href="#">Meet the team</a>
            </li>
            <li><a class="hsubs" href="#">Reviews</a>
                <ul class="subs">
                <li><a href="#">Reviews</a></li>
                <li><a href="#">Hints & Tips</a></li>
                </ul>
            </li>
          <li><a class="hsubs" href="#">Charity Events</a></li>
          <li><a href="#">Store</a></li>
          <li><a href="#">About Us</a></li>
          <li><a href="#">Account</a>
            <ul class="subs">
            <li><a href="#">LogIn</a></li>
            <li><a href="#">Register</a></li>
            <li><a href="#">Reset Password</a></li>
            </ul>
          </li>
        </ul>
    </div>
    <div class='LeftBody'></div>
    <div class='RightBody'>
        <form id="RegisterForm" method="POST" name="RegisterForm">
            <div class="FormElement">
              <input name="First_Name" type="text" required="required" class="TField" id="First_Name" placeholder="First Name">
            </div>
            <div class="FormElement">
                <input name="Last_Name" type="text" required="required" class="TField" id="Last_Name" placeholder="Last Name">
            </div>
            <div class="FormElement">
                <input name="Email" type="email" required="required" class="TField" id="Email" placeholder="Email">
            </div>
            <div class="FormElement">
                <input name="Password" type="password" required="required" class="TField" id="Password" placeholder="Password">
            </div>
            <div class="FormElement">
              <input name="Register" type="button" class="button" id="Register" value="Register">
            </div>
        </form>
    </div>
    <div class='Footer'></div>
</div>


</body>
</html>
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
Enzo
  • 1
  • [Little Bobby](http://bobby-tables.com/) says ***[your script is at risk for SQL Injection Attacks.](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php)*** Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php). Even [escaping the string](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string) is not safe! – Jay Blanchard Aug 10 '17 at 16:56
  • **Never store plain text passwords!** Please use ***PHP's [built-in functions](http://jayblanchard.net/proper_password_hashing_with_PHP.html)*** to handle password security. If you're using a PHP version less than 5.5 you can use the `password_hash()` [compatibility pack](https://github.com/ircmaxell/password_compat). ***It is not necessary to [escape passwords](http://stackoverflow.com/q/36628418/1011527)*** or use any other cleansing mechanism on them before hashing. Doing so *changes* the password and causes unnecessary additional coding. – Jay Blanchard Aug 10 '17 at 16:57
  • By the way nice web page title – HddnTHA Aug 10 '17 at 16:57
  • Add `ini_set('display_errors', 1);` right after you enable errors. – Jay Blanchard Aug 10 '17 at 16:58

1 Answers1

1

Change your input type button to submit

<input name="Register" type="submit" class="button" id="Register" value="Register">
Kalaivani M
  • 1,250
  • 15
  • 29