I wonder if someone could help me please.

I basically made a registration form and need to insert the data into the database.

I am not sure how i use the MySQL functions to do this,

I created a db connection file and included it on registration page but not sure if i first havew to query database then insert data etc, i am a little confused.

Before any data can be inserted it has to check if the email address and username already exist. Could someone plese give me the info on what order i do it?

here is what needs being added to database.

username, first_name, last_name, email, password

before it inserts the users data it needs to check to make sure the username and email does or does nto exist.

If someone could help me with this it would be much appreciated.

Here is my db connection file code in case it helps, this is included using the php include in the registration page. All i need help in how i got about checkning if username and email exists or not and if all ok put info in db or give an error to say it already exists.


// Database Connection Details

$host = "localhost"; // Usually Local Host
$user = "none"; // Database Username
$pass = "none"; // Database Password
$database = "usernone"; // Database Name

mysql_connect ($host, $user, $pass, $database);


Thank you,

7 Years
Discussion Span
Last Post by genieuk

In connection at localhost user is root and password is blank..

$con = mysql_connect("localhost","root","");
	if (!$con)
	  die('Could not connect: ' . mysql_error());
	 // echo('Connected with Mysql');
		@mysql_select_db("usernone", $con);

before inserting check data

$sql=mysql_query("select username from table where username=$name");
echo "user already exists";

You can change query according to your problem defination..
hope this will help you..



Thank you,

One question thou the first bit of code where it has mysql_connect , why do i need that? reason why i have that included with my db_connect.php file which i used an include on registration page, so i thought the whole point of that was to not have such information as db details actually on regsitration page but instead included from another file and use the php include function.

Also where do i actually put the code? i mean the first part of code not sure where that goes and does the second piece of code check both email and username? if i am rite it only checking for username not email aswell.

Thank you,

Maybe it be better if i put my registration form on here so you could have a look it may make more sence.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.