次のようなコードがあるとします。
<?php
include ('include/connectdb.php');
if(isset($_POST['tbn_submit'])){
$username = $_POST['text_username'];
$password = $_POST['text_password'];
$query = "SELECT * FROM tblusers WHERE `user_username`='".$username."' AND user_password='".$password."'";
$res = mysql_query($query) or die (mysql_error());
if($res){
if(mysql_num_rows($res)){
$user = mysql_fetch_assoc($res);
if($user['user_possition'] == "Admin"){
echo '<script type="text/javascript">window.location = "view_form.php"</script>';
}
else if($user['user_possition'] == "User"){
header("location:view_edit_uid.php?uid=".$user['user_id']);
//in this point I need to use javascript instead of php code but I do not know how to write it
}
else if($user['user_possition'] == "R1"){
echo '<script type="text/javascript">window.location = "view_form_res1.php"</script>';
}
else if($user['user_possition'] == "R2"){
echo '<script type="text/javascript">window.location = "view_form_res2.php"</script>';
}
}
else {
echo '<tr><td colspan="2"><center><b style="color:red;">Invalide username or password, please check again!</b></center></td></tr>';
}
}
}
?>
問題
$user['user_id']
次のようにjavascriptで使用する必要があります
`echo '<script type="text/javascript">window.location = "view_edit_uid.php?uid=".$user['user_id']</script>';`
$user['user_id']
しかし、javascriptではわからないため、機能しません。どうすればこれを修正できますか?
誰でも私を助けてください、ありがとう。