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 4093684
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:38:56+00:00 2026-05-20T19:38:56+00:00

I cant get if ($register_user_name != $check_name){ to work, the nested if staement work

  • 0

I cant get if ($register_user_name != $check_name){ to work, the nested if staement work properly though.

<?php
//al the default code to connect to mysql
include("../sql_information.php");

class infos{

    //the var that will store my sql query
    private $db;

    function login_details($queryresult) {

        //this runs the imported script
        $this->db = new MySQLDatabase();
        $register_user_name = $_POST['register_user_name'];
        $register_password = $_POST['register_password'];
        $confirm_password = $_POST['confirm_password'];
        //This is my mysql search query
        $sql = "SELECT user_name FROM `data_manager`.`user_accounts`;";
        //the result of the query is stored in this var
        $queryresult = $this->db->query($sql);

        //I dont know what I did here
        if ($result = $this->db->fetchArray($queryresult)) {

        $answer = $result['id'];

        $check_name = in_array($register_user_name, $answer);

        if ($register_user_name != $check_name){
            if ($register_password == $confirm_password) {
                $sql = "INSERT INTO `data_manager`.`user_accounts` (`id`, `user_name`, `password`) VALUES (NULL, '$register_user_name', '$register_password');";
                mysql_query($sql);
                echo "Registration Complete !";
            } else {
                print "The password you entered does not match, please retry.";
            }
        } else {
            print "This username is already being used !";
        }
    }
    }
?>
  • 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-05-20T19:38:57+00:00Added an answer on May 20, 2026 at 7:38 pm

    You are doing existing username check wrong way. You have to make database to do this check, not your code.

    $errors = array();
    $register_password = $_POST['register_password'];
    $confirm_password = $_POST['confirm_password'];
    //escape string going to the query
    $register_user_name = mysql_real_escape_string($_POST['register_user_name']);
    
    $sql = "SELECT 1 FROM data_manager.user_accounts WHERE user_name='$register_user_name'";
    $queryresult = $this->db->query($sql);
    if ($this->db->fetchArray($queryresult)) {
      $errors[] = "Username already taken";
    }
    if ($register_password !== $confirm_password) {
      $errors[] = "Passwords mismatch";
    }
    if (!$errors) {
      $register_password = mysql_real_escape_string($register_password);
      $sql = "INSERT INTO `data_manager`.`user_accounts` (`id`, `user_name`, `password`) 
                              VALUES (NULL, '$register_user_name', '$register_password')";
      mysql_query($sql);
      header("Location: cpanel.php");
      exit;
    } else {
      foreach ($errors as $err) echo $err;
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Cant get this script to work with my menu really have tried everything any
I cant get jquery's date picker to work on my page. I have a
I cant get a PHP file to send correct headers at my WAMP server.
I'm probably doing something realy stupid but I cant get this to work: var
I cant get DependencyProperty.Register to work. It requires (string, string, string, PropertyMetadata) instead of
Probably I cant get more dumb, but seriously this is the first time I
Can someone explain why i cant get the desired delay between each request? They
I have an issue I cant get to the bottom of, so any help
so i am making a temp converter and i just cant get it to
I am working the location service in iphone and I cant get any location

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.