表单里面有下面的表格:
<td width="221"><p>
<label>
<input type="radio" name="RadioGroup" value="a" id="RadioGroup_0" onclick=submit();/>
<font face="华文行楷">管理员</font>
</label>
<label>
<input type="radio" name="RadioGroup" value="b" id="RadioGroup_1" onclick=submit();/>
<font face="华文行楷">学生</font></label>
<br />
</p></td>
各位大侠们,写到这一步进行不下去了,不知道怎样用php得到radio的value,。如果value值为a,则跳转到一个页面,为b则跳转另一个页面。也就是要使选管理员跟选学生跳转到不同的页面。中间层的php代码应该怎么写呢????下面是我写的判断登陆的php文件:
<?php
if($_POST['username']!=""&&$_POST['password']!="")
{
$con = mysql_connect("localhost", "root", "root");
$db_selected = mysql_select_db("dormmanagement",$con);
$sql1="SELECT *FROM administrators WHERE Aname= '".$_POST['username']."'AND Apassword= '".$_POST['password']."';";
$result=mysql_query($sql1);
$rows=mysql_num_rows($result);
if($rows==0)
{
echo "<script language=\"javascript\">
alert(\"对不起!账号或密码错误,请重新登录!\");location.href='index.php';
</script>";
exit();
}
else if($_POST['a']!="")
{
header("Location:stuindex.html");
}
else header("Location:admindex.html");
}
else
{
echo"<script language=\"javascript\">
alert(\"用户名或密码不能为空!请重新登录!\");
location.href='index.php';
</script>";
exit();
}
?>
<td width="221"><p>
<label>
<input type="radio" name="RadioGroup" value="a" id="RadioGroup_0" onclick=submit();/>
<font face="华文行楷">管理员</font>
</label>
<label>
<input type="radio" name="RadioGroup" value="b" id="RadioGroup_1" onclick=submit();/>
<font face="华文行楷">学生</font></label>
<br />
</p></td>
各位大侠们,写到这一步进行不下去了,不知道怎样用php得到radio的value,。如果value值为a,则跳转到一个页面,为b则跳转另一个页面。也就是要使选管理员跟选学生跳转到不同的页面。中间层的php代码应该怎么写呢????下面是我写的判断登陆的php文件:
<?php
if($_POST['username']!=""&&$_POST['password']!="")
{
$con = mysql_connect("localhost", "root", "root");
$db_selected = mysql_select_db("dormmanagement",$con);
$sql1="SELECT *FROM administrators WHERE Aname= '".$_POST['username']."'AND Apassword= '".$_POST['password']."';";
$result=mysql_query($sql1);
$rows=mysql_num_rows($result);
if($rows==0)
{
echo "<script language=\"javascript\">
alert(\"对不起!账号或密码错误,请重新登录!\");location.href='index.php';
</script>";
exit();
}
else if($_POST['a']!="")
{
header("Location:stuindex.html");
}
else header("Location:admindex.html");
}
else
{
echo"<script language=\"javascript\">
alert(\"用户名或密码不能为空!请重新登录!\");
location.href='index.php';
</script>";
exit();
}
?>
if(radio=="a"){
//do something
}
else{
//do something
}
你在html页面加一个form,之后进行跳转啊!或者用js进行跳转到哪个页面,并且将radio的值也顺便传过去!
if(radio=="a")
{
header("Location:admindex.html");
}
else header("Location:stuindex.html");
但这样不行啊,始终执行else的内容,if里的根本不执行
可以加你QQ帮我改下吗?
我又很多php方面的问题。。
index里面这样
<form action="loading.php" method="post" >
<input type="hidden" id="action" name="action" value="submit" />
<td width="221"><p>
<label>
<input type="radio" name="RadioGroup" value="a" id="RadioGroup_0" onclick=submit();/>
<font face="华文行楷">管理员</font>
</label>
<label>
<input type="radio" name="RadioGroup" value="b" id="RadioGroup_1" onclick=submit();/>
<font face="华文行楷">学生</font></label>
<br />
</p></td>
<input type="submit" id="submit" name="submit" value="提交" />
</form>
loading里面这样$RadioGroup= trim($_POST[RadioGroup]);
$RadioGroup=trim($_POST[RadioGroup]);
if($RadioGroup)//if语句里面该怎么写?
{
header("Location:admindex.html");
}
else header("Location:stuindex.html");始终只执行上面的,我要怎么样才能实现呢?
$name=$_POST['RadioGroup'];
if($name=='a'){
header("Location:admindex.html");
}else{
header("Location:stuindex.html");
}
?>