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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:06:10+00:00 2026-05-16T12:06:10+00:00

I just started with PHP and my SQL databases, I have learned how to

  • 0

I just started with PHP and my SQL databases, I have learned how to create databases, and create register forms that store the information on the databases, but I do not know how to keep people from being able to register with a user name that has already been taken, and I don’t know how to allow users to have their own profile page on my website. Do you know how? I am using XAMPP to test my databases and PHP code on my local server, if that help in any way.
Here is my PHP code:

<?php
$con=mysql_connect("localhost", "root", "" );
if (!$con)
{
  die('Could not connect: ' . mysql_error());
}
$username=$_POST['username'];
$password=$_POST['password'];
$email=$_POST['email'];

mysql_select_db("test", $con);

mysql_query("INSERT INTO users (id, username, password, email)
  VALUES (NULL,'$username', MD5('$password'), '$email')");

if (my_query) 
  echo "Account Successfully Created";
else
  echo "Sorry Could Not Create Account !";

mysql_close($con);
?>
  • 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-16T12:06:11+00:00Added an answer on May 16, 2026 at 12:06 pm

    PLEASE make sure you read up on SQL injections before continuing. It’s good to get good MySQL habits early!

    You’ll need to change the following SQL query to fit your current database structure, but you should see the pattern of what’s going on –

    $getSQL = "SELECT * FROM users WHERE username = '$username';";
    $getResult = mysql_query($getSQL);
    if(mysql_num_rows($getResult) > 0) { // This username is already taken } else { // This is a new username }
    

    As far as a profile page, create a viewprofile.php file that takes the user’s ID, and the following code should get you going in the right direction.

    $getSQL = "SELECT * FROM users WHERE id = '$id';";
    $getResult = mysql_query($getSQL);
    if(mysql_num_rows($getResult) > 0) {  
    
        // The profile being viewed exists
    
        while($gR = mysql_fetch_array($getResult)) {
            $userid = $gR['id'];
            $username = $gR['username'];
        }
    
    } else { 
    
        // The profile being viewed doesn't exist
    }
    

    I really hope this helps you! Some other good resources for you: MySQL Tutorial, Basic User Authentication Tutorial,

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

Sidebar

Ask A Question

Stats

  • Questions 500k
  • Answers 500k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Resetting the src attribute to fire the load handler seems… May 16, 2026 at 1:57 pm
  • Editorial Team
    Editorial Team added an answer Shouldn't you be using yy instead of yyyy per the… May 16, 2026 at 1:57 pm
  • Editorial Team
    Editorial Team added an answer Internal indexing in a database and the index that a… May 16, 2026 at 1:57 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Just started designing a database which I have not done before. And am wondering
I have a completed web app in PHP 5 + MySQL. I have not
I have just started using services in Android and I have a made a
Just today I've started using Drupal for a site I'm designing/developing. For my own
Quick background: I'm programming in PHP, I have a domain model with a separate
We have a custom software project that's database driven (MySQL) and is built with
i just started two weeks ago with ObjectiveC and i'm a complete noob so,
I just started studying C++, and I met this new guy: ->. I was
I just started reading a Java book and wondered; which access specifier is the
I just started creating my first WP theme after doing the HTML/CSS. All good

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.