0

Whenever I try to send this through to my database, it returns the PHP code I use. I made sure that xampp was running localhost, but there seems to be a problem. My localhost does say "The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. Find out why. Or alternately go to 'Operations' tab of any database to set it up there." The top is my PHP code, and then it's the register.html which is where it is supposed to be used. Thank you for your help!

<?php

$name = $_POST['name'];
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$phone = $_POST['phone'];

if (!empty($name) || !empty($username) || !empty($password) || !empty($email) || !empty($phone)) {

      $host = "localhost:80";
    $dbUsername = "root";
    $dbPassword = "";
    $dbname = "pracdata";


    //create connection
    $conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
    if (mysqli_connect_error()) {
     die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
    } else {
     $SELECT = "SELECT email From users Where email = ? Limit 1";
     $INSERT = "INSERT Into users (name, username, password, email, phone) values(?, ?, ?, ?)";


     //Prepare statement
     $stmt = $conn->prepare($SELECT);
     $stmt->bind_param("s", $email);
     $stmt->execute();
     $stmt->bind_result($email);
     $stmt->store_result();
     $rnum = $stmt->num_rows;

     if ($rnum==0) {
      $stmt->close();
      $stmt = $conn->prepare($INSERT);
      $stmt->bind_param("ssssii", $username, $username, $password, $email, $phone);

      $stmt->execute();
      echo "Your account has been registered!";
     } else {
      echo "This email is already linked to Preak account";
     }
     $stmt->close();
     $conn->close();
    }
} else {
 echo "All fields are required";
 die();
}
?>
<!DOCTYPE html>
<html>

    <head>

    <!-- init -->

        <title>Register a Prac account</title>
        <link href="https://fonts.googleapis.com/css?family=Roboto+Mono:100,400&display=swap" rel="stylesheet">
        <link rel="stylesheet" type="text/css" href="style.css">
        <script src="index.js"></script>

    </head>

    <body>

        <h1>Register, and join the fun!</h1>


        <div class="sign-up-form">


      <!-- form serves no actual purpose, yet. Doesn't have information-->
            <form action="users.php" method="POST">
        <!-- User's name -->
                <input type="name" class="input-box" name="name" placeholder="Full Name" required><br><br>
        <!-- Username -->
                <input type="username" class="input-box" name="username" placeholder="Username" required><br><br>
        <!-- password -->
                <input type="password" class="input-box" name="password" placeholder="Password" required><br><br>
        <!-- email-->
                <input type="email" class="input-box" name="email" placeholder="Email" required><br><br>
        <!-- phone # -->
                <input type="phone" class="input-box" name="phone" placeholder="Phone Number" required><br><br>

        <!-- buttons -->
        <!-- register button, acc means actual, don't know why 2 'C's'-->
                <input type="Submit" value="Register Now" id="registeracc-button"><br><br>
        <!-- sign in button, leads to sign in page-->
                <button id="Sign-in-button"><a href="login.html" class="special">Sign in</a></button>
        <!-- sign in as guest goes to homepage, cannot post -->
                <button id="LoginasGuest-button"><a href="index.html" class="special">Sign in as Guest</a></button>
        <!-- submit details -->

            </form>

        </div>

    </body>

</html>
  • 2
    Does this answer your question? [PHP code is not being executed, instead code shows on the page](https://stackoverflow.com/questions/5121495/php-code-is-not-being-executed-instead-code-shows-on-the-page) – El_Vanja Mar 28 '20 at 18:05
  • 1
    **Never store passwords in clear text or using MD5/SHA1!** Only store password hashes created using PHP's [`password_hash()`](https://php.net/manual/en/function.password-hash.php), which you can then verify using [`password_verify()`](https://php.net/manual/en/function.password-verify.php). Take a look at this post: [How to use password_hash](https://stackoverflow.com/q/30279321/1839439) and learn more about [bcrypt & password hashing in PHP](https://stackoverflow.com/a/6337021/1839439) – Dharman Mar 28 '20 at 18:22

0 Answers0