Current location: Hot Scripts Forums » Programming Languages » PHP » PHP check if username exist when registrate

PHP check if username exist when registrate

  #1 (permalink)  
New Member
Join Date: Dec 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
PHP check if username exist when registrate

When people registert to my webpage i want the code to check in the msql if it already exist. now people can creat 2 users called admin, 2 users called "username" and so on. i want so when they registrate it says"Oh sorry, that usrename is in use!"

This is the code that check and post their username, passwords, email, number and so on to the mysql table.
PHP Code:


//=============Configuring Server and Database=======
$host        =    'localhost';
$user        =    'root';
$password    =    '';
//=============Data Base Information=================
$database    =    'login';
$conn        =    mysql_connect($host,$user,$password) or die('Server Information is not Correct'); //Establish Connection with Server
mysql_select_db($database,$conn) or die('Database Information is not correct');
//===============End Server Configuration============
//=============Starting Registration Script==========

$Rank    =    mysql_real_escape_string($_POST['txtRank']);

$rights    =    mysql_real_escape_string($_POST['txtrights']);

$points    =    mysql_real_escape_string($_POST['txtpoints']);

$email    =    mysql_real_escape_string($_POST['txtemail']);

$nummer    =    mysql_real_escape_string($_POST['txtnummer']);
$password    =    mysql_real_escape_string($_POST['txtPassword']);

$username    =    mysql_real_escape_string($_POST['txtusername']);
//=============To Encrypt Password===================

//============New Variable of Password is Now with an Encrypted Value========
if(isset($_POST['btnRegister'])) //===When I will Set the Button to 1 or Press Button to register
$query    =    "insert into users(rights,Rank,points,email,nummer,username,password)values('$rights','$Rank','$points','$email','$nummer','$username','$password')";
$res    =    mysql_query($query);

Reply With Quote

Featured Marketplace Scripts (view more)



database, html, mysql, php

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Check if username exists in the Database bindip PHP 7 04-09-11 11:40 AM
Check if username or email already exists zitwep PHP 4 10-13-10 09:13 AM
PHP programmer to edit exist website Dr-SeMSeM Job Offers & Assistance 1 11-20-07 10:50 PM
Quick Question for you php guru's Tokahashi PHP 3 04-09-04 12:00 PM
PHP: check data transfer on certain directories? Agum PHP 7 12-30-03 03:58 AM

All times are GMT -5. The time now is 07:31 PM.
vBulletin® Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.