Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9135207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:47:38+00:00 2026-06-17T08:47:38+00:00

I am trying to allow for user registration, and the code comes back without

  • 0

I am trying to allow for user registration, and the code comes back without any errors, but nothing shows up in my db. I can’t for the life of me find out why. I don’t see anything wrong, but maybe one of you can help me?

Here’s the full php file:

<?php

require "includes/constants.php";

$conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME);

if(isset($_POST['username'])) {
    $username = $_POST['username'];
    $uLength = strlen($username);
}

if ($uLength >= 4 && $uLength <= 15)
{
}
else
{
    die("Your username must be between 4 and 15 characters.");
}

if($username == "")
{
    die("You didn't tell me what to call you! Please enter a username.");
}

if(isset($_POST['pwd'])) {
    $pwd = $_POST['pwd'];
    $pLength = strlen($pwd);
}

if ($pLength >= 6 && $pLength <= 41)
{
}
else
{
    die("Password must be between 6 and 41 characters.");
}

if($pwd == "")
{
    die("Please enter a password and verify it.");
}

if(isset($_POST['pwd_conf'])) {
    $pwd_conf = $_POST['pwd_conf'];
}
if($pwd != $pwd_conf)
{
    die("Ouch! Your passwords don't match! Try again.");
}

if(isset($_POST['email'])) {
    $email = $_POST['email'];
    $email1 = "@";
    $email_check = strpos($email,$email1);
}

$user_check = "SELECT username FROM users WHERE username='$username'";
if($stmt = mysqli_prepare($conn,$user_check)) {
    mysqli_stmt_execute($stmt);

    if(mysqli_stmt_num_rows($stmt) > 0){
        die("Username is already in use!<br>");
    }
}

$query = "INSERT INTO users (username, password, email) VALUES ('$username', '$pwd', '$email')";

if(!$query)
{
    die("Unfortunately, we can't sign you up because we have problems: ".mysql_error());
}
else
{
    header("Location: login.php");
}

?>    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:47:39+00:00Added an answer on June 17, 2026 at 8:47 am

    You build a query string, but then never never execute it…

    1. $sql = "INSERT ..."
    2. ???
    3. come to SO to ask why
    

    Also note that you’re mixing mysqli and mysql calls (mysql_error call in particular after you define the INSERT query.. The two libraries are NOT interchangeable and NOT compatible with each other

    Also note that while you ARE using prepared statements (yay!) you’re using them utterly incorrectly (boo hiss) and are vulnerable to SQL injection attacks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to expand the devise registration form to allow a new user
The code itself is pretty basic. I am trying to allow user to connect
I'm trying to allow the user to edit a contenteditable div, but am finding
i'm trying to allow user to upload multiple images but when i validate the
Greetings, I'm trying to allow my user to close the app but still maintain
Trying to allow a user to type into a textarea, but if a certain
In this code I'm trying to allow the user to grab the black square
I have the following code where I'm trying to allow the user to open
I'm trying to build a registration module where user can only register if their
I'm trying to allow user to rename file name, after taking picture, but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.