表单里面有下面的表格:
<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();
}
?>

解决方案 »

  1.   

    你直接将radio的值传到服务端进行判断不就好了嘛!
    if(radio=="a"){
    //do something
    }
    else{
    //do something
    }
    你在html页面加一个form,之后进行跳转啊!或者用js进行跳转到哪个页面,并且将radio的值也顺便传过去!
      

  2.   

    登陆页面为首页,为index.php,处理登陆的页面为loading.php,你是说在loading.php文件中这样写吗:
    if(radio=="a")
    {
    header("Location:admindex.html");
    }
    else header("Location:stuindex.html");
    但这样不行啊,始终执行else的内容,if里的根本不执行
    可以加你QQ帮我改下吗?
    我又很多php方面的问题。。
      

  3.   


    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]);
      

  4.   

    还是无法实现点管理员时跳转到一个页面,点学生时跳转到另一个页面啊?
    $RadioGroup=trim($_POST[RadioGroup]);
    if($RadioGroup)//if语句里面该怎么写?
    {
    header("Location:admindex.html");
    }
    else header("Location:stuindex.html");始终只执行上面的,我要怎么样才能实现呢?
      

  5.   

    我觉得应该是:<?php 
    $name=$_POST['RadioGroup'];
    if($name=='a'){
    header("Location:admindex.html");
    }else{
    header("Location:stuindex.html");
    }
    ?>