mbabaali 0 Newbie Poster

am using a select option on the html form and i want to insert the username and password if it does exist basing on a category selected form the select list if the user select administtrator as the category the username and password shd be inserted in the admin table otherwise if the category is Normal user it should insert them in user table but it brings an error "username is ambigious in the list" below is the code

<?php 
// Connects to your Database 
require_once('Connections/Database.php');
mysql_select_db($database_Database, $Database);
//This makes sure they did not leave any fields blank
if (!$_POST['username'] | !$_POST['cat'] | !$_POST['pass'] | !$_POST['pass2'] ) {
die('You did not complete all of the required fields');
}

// checks if the username is in use
if (!get_magic_quotes_gpc()) {
$_POST['username'] = addslashes($_POST['username']);
}
$usercheck = $_POST['username'];
$check = mysql_query("SELECT username FROM users,admin WHERE username = '$usercheck'") 
or die(mysql_error());
$check2 = mysql_num_rows($check);

//if the name exists it gives an error
if ($check2 != 0) {
die('Sorry, the username '.$_POST['username'].' is already in use.');
}

// this makes sure both passwords entered match
if ($_POST['pass'] != $_POST['pass2']) {
die('Your passwords did not match. ');
}



$a=$_POST['username'];
$b=$_POST['pass'];
$c=$_POST['cat'];
if($c="Normal user")
{$insert="insert into users values('$a','$b')";

$checkresult=mysql_query($insert);
if ($checkresult) echo 'User successfully added'; 
else echo 'query failed user not added'; }

else{if ($c="administrator")
{$inserts="insert into admin values('$a','$b')";

$checkresults=mysql_query($insert);}
if ($checkresults) echo 'User successfully added'; 
else echo 'query failed user not added'; 
}

mysql_close();
?>

pliz help me out thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.