2015-06-08 103 views
0

我想在系統中註冊user.two類型的用戶註冊後重定向不同的網頁。但它們只能重定向到(conduct.php)頁面。多用戶登錄重定向php中的不同頁面

register.php

<?php 

//session_start(); 
include('connect.php'); 

if(isset($_POST['submit'])){ 

extract($_POST); 

var_dump($_POST); 

$mysql_query = mysql_query("INSERT INTO `iportal`.`signup` (
             `registation_no` , 
             `name` , 
             `batch` , 
             `stream` , 
             `email` , 
             `username` , 
             `password` , 
             `isuser` 
             ) 
VALUES (
'$registrationnumber', '$fullname', '$batch', '$stream', '$email', '$username', '$password', '$isUser' 
) 
"); 

if($isUser=0){ 

    header("Location: practical.php"); 
    } 

if($isUser=1){ 

    header("Location: conduct.php"); 
} 

} 
?> 
+0

在PHP對比在==進行使用和測試 –

+0

我想我是在重定向錯誤的方式。所以我問這個問題。謝謝! –

回答

0

您應該使用compairson運營商即==

if($isUser==0){ //correct it 
    header("Location: practical.php"); 
} 
if($isUser==1){ //correct it 
    header("Location: conduct.php"); 
} 

希望它能幫助。

+1

謝謝,它的工作原理。 –

0

PHP中的比較由=====完成。

if ($isUser == 0) { 
    header("Location: practical.php"); 
} elseif ($isUser == 1) { 
    header("Location: conduct.php"); 
} 

或者用else

if ($isUser == 0) { 
    header("Location: practical.php"); 
} else { 
    header("Location: conduct.php"); 
} 
+1

謝謝它的作品! –

+0

您正在使用單獨的if條件來檢查用戶類型。這兩個條件都是正在處理的。這不是很好的做法@sandun tharaka。 而且你正在使用錯誤的比較運算符。你必須使用'=='運算符進行比較。 –