我应该怎么做PHP

时间:2015-11-07 11:44:49

标签: php html

我想我在usertype 3上有一个错误因为它总是去通知,如果我改变通知和plsvote.php它只会刷新所以请帮我做什么

if (isset($_POST['login'])){
    $idno = $_POST['idno'];
    $password = $_POST['password'];
    $position = $_POST['user_type'];


    $sql1 = "SELECT * FROM users WHERE idno = '$idno' AND password = '$password'";
    $result = mysql_query($sql1) or die();
    $row = mysql_fetch_array($result);
    $num_row = mysql_num_rows($result);



//if the user is admin
    if ($row['user_type'] == "1"){

        mysql_query("insert into user_log (idno,login_date) values('$username',NOW())")or die(mysql_error());
        $YearNow=Date('Y');
                    header('location:admin/index.php');

    }
    //if the user is student
        else if ($row['user_type'] == "3") {

                $sql_c = "SELECT * FROM users,studentvotes,school_year = users.idno = studentvotes.idno AND studentvotes.syearid =school_year.syearid AND school_year.from_year like $YearNow  ";


                $result1 = mysql_query($sql_c) or die(mysql_error());
                while($row2=mysql_fetch_array($result1)){

                $_SESSION['SESS_COURSE'] = $row2['progid'];       
                $_SESSION['SESS_MEMBER_ID'] = $idno;

                //$query = mysql_query ("INSERT INTO user_log VALUES('$idno',NOW(), 'Login') ") or die(mysql_error());
                header('location:plsvote.php'); 
            }   
            }

                else{
            header('location:notification.php');
            exit();
            }
    }

0 个答案:

没有答案