Hello all of you,,,,,,,,

Currently i am facing a problem.....problem is that.i am using two table admin or customer.I have one form.....i want when i select admin button then it will insert the values into admin table and when i will select customer button then it will insert into the customer table....here is my form.....

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong> Login Page </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="username" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="password" type="text" id="mypassword"></td>
</tr>
<tr>
<td><INPUT TYPE="radio" NAME="page" VALUE="admin" <?PHP print $admin_status; ?> >Admin</td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><INPUT TYPE="radio" NAME="page" VALUE="customer" <?PHP print $customer_status; ?> >Customer</td>

</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</body>
</html>

i do not want to insert the value of radio button......

plz reply me.....

Hi
Easy
with an if statement

// put this code at the top of the page to check if the page is posted back or not
 // and check that the value of radio is not empty
   if(isset($_POST['page']) && !empty($_POST['page'])){
        // put your logic here
    }
<?PHP
if (isset($_POST['Submit']))
{
$selected_radio = $_POST['page'];

if ($selected_radio = = 'admin') 
{
echo "include("adminfetch.php")";
}
else if ($selected_radio = = 'customer') 
{
echo "include("customerfetch.php")";
}
}

?>

this is my code..

Thanks for your reply

is this correct or wrong method........if wrong then try to correct this....

First you have to check if the user chosen one value from the 2 radio
because the user can submit the form without choose any thing .
second thing that don't use echo to include the file because it will print the pass to the user instead use include directly

<?PHP
if(isset($_POST['Submit']) && !empty($_POST['page'])){
	$selected_radio = $_POST['page'];
	if($selected_radio == 'admin'){
		include("adminfetch.php");
	}else if ($selected_radio == 'customer'){
		include("customerfetch.php");
	}	
}

?>

try this.

A very very thanks for this code this is very helpfull.....

this is working very fine....which output i want

So the problem was solved..
but I recommend to add some validation on the user-name and password text-box to check of the user added any value before submit the form
and I recommend to use JavaScript to validate the form on the client side and add the the server side validation for an extra check

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.