lets indent your code, and put the same statements into the same level.
In your original code, that is not a good idea to determine if the user has used with a "email" query.
In this code lets see the variable name!
(a variable should not placed as a function)
$checkemailsql( "SELECT * from tbl_admin_users where email='$email'" ); //if
Lets use functions to test if the user or email already in the table (i did not test it, but this version should a better way :
<?php
include_once( 'includes/connector.php' );
function ise( $var )
{
if ( empty( $_POST["$var"] ) )
return "$var need to be filled! <br />";
}
function checkdata($var , $msg){
$checkemailsql=sprintf( "SELECT * from `tbl_admin_users` where %s='%s'",$var , $_POST["$var"] );
$chk= mysql_query( $checkusersql );
if ( mysql_num_rows( $chk) > 0 ) // if value exists
{
return "$msg is already exists";
}
}
if ( $_POST['submit_form'] == 1 )
{
$message = "";
$message .= ise( "username" );
$message .= ise( "password" );
$message .= ise( "email" );
$message.=checkdata("username","Username");
$message.=checkdata("email","Email");
if ( !empty( $message ) )
die( $message );
$_POST = array_map( "mysql_real_escape_string", $_POST );
$username = $_POST["username"];
$email = $_POST["email"];
$password = $_POST["email"];
$reult= mysql_query( "INSERT into `tbl_admin_users` (username,password,email) values($username, md5( $password ) ,$email)" );
$message = "User has been added";
}
?>