0

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.....

2
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by mahmoud_wow
0

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
    }
0
<?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..

0

Thanks for your reply

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

0

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.

Edited by mahmoud_wow: n/a

0

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

This topic has been dead for over six months. 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.