Display a popup window in users space not in admin

Hi, Guys…I got struck in middle of my project…Here am going to give the scenario,pls provide me the resolution to sort out.

At the time of login the user should ask to select his case by a pop up window(using java script,php,mysql).This should be given by the admin,whereas here the admin also getting same pop up window which he is not supposed to.

I want to disable the pop up window in admin space,only it should be available during user session.

regards,
Nandha.

//Code//

<?
include ‘config/connect.php’;

session_start();
ob_start();

$userper_caseid=$_SESSION[‘userper_caseid’];
$uname=$_SESSION[‘user_name’];

$Submit=$_POST[‘Submit’];

if($Submit==“Submit”)
{
$updatecase2=mysql_query(“update users_permission set user_view_status=‘0’ where username=‘$uname’”);
//$id=$_REQUEST[‘id’];
$user_view_status=$_POST[‘user_view_status’];
$coid=count($user_view_status);
//echo $coid;
//exit;

if($coid&gt;0)
{


//echo "hai";
 //exit;
 
  for($i=0;$i&lt;count($user_view_status);$i++)
  {
   $user_case=$user_view_status[$i];
  
  $updatecase=mysql_query("update users_permission set user_view_status='1' where id='$user_case' and username='$uname'");
  $updatecase1=mysql_query("update users_permission set user_view_status='0' where id!='$user_case' and username='$uname'");
  //echo $uname;
//exit;

 }
}

//echo "hey";
//exit;
 //echo $updatecase2;
 //exit;

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

//$a=$_SESSION[‘id’];

//$selcaseids=“select * from users_permission where id=‘id’”;
//$secaid=mysql_query(selcaseids);
//$sefetca=mysql_fetch_assoc(secaid);

//$casel=$sefetca[‘userper_caseid’];

?>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=“http://www.w3.org/1999/xhtml”>

<head>

<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />

<title>Jon Duncan-DMS</title>

<link rel=“stylesheet” type=“text/css” href=“css/menu.css” />

<link rel=“stylesheet” type=“text/css” href=“css/accordion_style.css” />

<link rel=“stylesheet” type=“text/css” href=“js/style.css” />

<!–[if lte IE 7]>

<style type=“text/css”>

html .jqueryslidemenu{height: 1%;} /Holly Hack for IE7 and below/

</style>

<![endif]–>

<style type=“text/css”>

<!–

@import url(“css/style.css”);

body {

margin-left: 0px;

margin-top: 0px;

margin-right: 0px;

margin-bottom: 0px;

background-image: url(images/body_bg.jpg);

background-repeat: repeat-x;

background-color: #FCFDFF;

}

–>

</style>

<style type=“text/css”>

<!–

@import url(“css/style.css”);

body {

margin-left: 0px;

margin-top: 0px;

margin-right: 0px;

margin-bottom: 0px;

background-image: url(images/body_bg.jpg);

background-repeat: repeat-x;

}

.style1 {font-family: Arial, Helvetica, sans-serif}
.style2 { font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
}

–>

</style>

</head>

<body>

<div class=“maincontainer”>
<?php //include(‘includes/mainheader.php’);?>
<div class=“mainconten”>

  &lt;table width="100%" border="0" cellspacing="0" cellpadding="0"&gt;
   
    &lt;tr&gt;
      &lt;td valign="top"&gt;&nbsp;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top"&gt;&lt;div align="right"&gt;&lt;a href="javascript:(clientwin.close()"&gt;close&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td align="center" valign="top"&gt;&lt;div align="center"&gt;


      &lt;form name="" action="" method="post"&gt;
&lt;p&gt;&nbsp;&lt;/p&gt;
&lt;table width="361" height="140" class="gridtable"&gt;

<tr>
<td width=“91” class=“header”>Select Case : </td>
<td width=“258”>
<label>

<select name=“user_view_status” id=“user_view_status” multiple=“multiple” style=“width:100px;”>

          &lt;option value=""&gt;Select Cases&lt;/option&gt;
              &lt;?php
				     //$id=$_POST['id']; 
				   	 $selcaseids="select * from users_permission";
                     $secaid=mysql_query($selcaseids);
                       while($sefetca=mysql_fetch_assoc($secaid))
                        {
                         $id=$sefetca['id'];
                         $casel=$sefetca['userper_caseid'];
                 ?&gt;
    &lt;option value="&lt;?php echo $id;?&gt;" selected="selected" &gt;&lt;?php echo $casel;?&gt;&lt;/option&gt;
              &lt;?php } ?&gt;

</select>
</label>
</td></tr>
<tr>
<td></td>
<td>
<p>
<label>
<input type=“submit” name=“Submit” id=“Submit” value=“Submit” />
</label>
</p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
</form>
</div></td>
</tr>

    &lt;tr&gt;
      &lt;td valign="top"&gt;&nbsp;&lt;/td&gt;
    &lt;/tr&gt;


    &lt;tr&gt;
      &lt;td valign="top"&gt;&nbsp;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;

      &lt;td valign="top"&gt;&nbsp;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;

</div>

<div id=“footer”>
<table width=“80%” border=“0” cellspacing=“0” cellpadding=“0”>
<tr>
<td width=“33%” align=“right” valign=“top”> </td>
<td ><? //include(‘designs/footer.php’);?>
</td>
</tr>
</table>
</div>
</div>

</body>

</html>

INDEX.PHP

<?php

error_reporting(E_ALL && E_PARSE);
session_start();
ob_start();

include ‘classes/user.class.php’;

$login=$_POST[‘log’];
if(isset($_POST[“log”]) || isset($_POST[“log_x”]))

     {

       $user_name=($_POST['user_name']); 

	   $password=($_POST['password']); 

	   $selectQuery="SELECT * FROM dms_usermaster WHERE user_name='".$user_name."' and password='".$password."' and status='active'";

	   $resultSet=mysql_query($selectQuery)or die ('I cannot connect to the selectQuery: ' . mysql_error());


	   $numRows=mysql_num_rows($resultSet);

	   $rowSet=mysql_fetch_assoc($resultSet);

	   $rowSet['user_name'];
	  // $usertype=$rowSet['user_name'];
	   $u_role=$rowSet['u_role'];
	   
	   		//   $selectQuery1="SELECT * FROM dms_role_type WHERE dms_role_type_master='".$user_name."' and password='".$password."' and status='active'";


		 if($numRows&gt;0)

				{	

				  //$_SESSION['uname']=$uname;

						$_SESSION['password']= $rowSet['password'];
						$_SESSION['user_name']= $rowSet['user_name'];
						$_SESSION['u_role']= $rowSet['u_role'];

						header("location: home.php");

				}
				/* if($numRows&gt;0 &&  $u_role=="Stafff")

				{	

				  //$_SESSION['uname']=$uname;

						$_SESSION['password']= $rowSet['password'];
						$_SESSION['user_name']= $rowSet['user_name'];
						$_SESSION['u_role']= $rowSet['u_role'];

						header("location: userhome.php");

				}*/

			else{

				$errorMSG="Username and Password do not match. Please try again.";

	}	

}

?>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />
<title>Jon Duncan-DMS</title>
<style type=“text/css”>
<!–
@import url(“index_files/layout.css”);
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-image: url(index_files/bg2.jpg);
background-repeat: repeat;
}
–>
</style>

<script type=“text/javascript”>
<!–
function myPopup2() {
window.open( “clientwin.php”, “myWindow”,
“status = 1, height = 300, width = 300, resizable = 0” )
}
//–>
</script>

<script>
function PopupCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, ‘toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=’+w+‘, height=’+h+‘, top=’+top+‘, left=’+left);
}
</script>

<script type=“text/javascript”>

function checkForm(form1) {

if(document.form1.user_name.value=="")

{
	alert("Please Enter The UserName");

	document.form1.user_name.select()

	return false;
}

if(document.form1.password.value=="")

{
	alert("Please Enter The Password");

	document.form1.password.select()

	return false;
}

}
</script>
</head>

<body>
<div align=“center” id=“loginarea”>
<div class=“loginboxe”>
<form id=“form1” name=“form1” method=“post” action=“” onsubmit=“return checkForm(form1)”>
<table width=“313” border=“0” cellspacing=“0” cellpadding=“0”>

&lt;tr&gt;
  &lt;td align="left" valign="middle"&gt;&lt;?php  if($errorMSG!="")

		{

	?&gt;&lt;?php echo "Username and Password incorrect"; ?&gt;
          &lt;?php } ?&gt;         &lt;/td&gt;
&lt;/tr&gt;
  
   
  
 &lt;tr&gt;
  &lt;td align="left" valign="middle"&gt;User Name :        
    &lt;input name="user_name" type="text" class="homelog" id="user_name" /&gt;
    &lt;script&gt;document.getElementById('user_name').focus()&lt;/script&gt;

    &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td align="left" valign="middle"&gt;Password :
    &lt;input name="password" type="password" class="homelog" id="password" /&gt;&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
  &lt;td align="center" valign="middle"&gt;&lt;div align="center"&gt;
   
    &lt;input name="log" type="image"  id="log" value="Submit" src="index_files/login.png"  onclick="myPopup2()"/&gt;
   
  &lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;

</table>
<p><a href=“javascript:void(0);” onclick=“PopupCenter(‘forgot.php’, ‘myPop1’,400,200);”>
Forgot Password</a></p>
</form>
</div>
</div>
</body>
</html>

Essentially:



// your html


<?php
if( user is NOT admin){

echo '<p><a href="javascript:void(0);" onclick="PopupCenter(\\'forgot.php\\', \\'myPop1\\',400,200);">';

}
?>


// carry on with your html


Now how do you work out whether someone is admin or not? Put that test inside the if() clause instead of that pseudocode.



my code


&lt;?php
if($u_role!='admin'){

echo '&lt;p&gt;&lt;a href="javascript:void(0);" onclick="PopupCenter(\\'forgot.php\\', \\'myPop1\\',400,200);"&gt;';

}
?&gt;

javascript code:

&lt;script type="text/javascript"&gt;
&lt;!--
function myPopup2() {
window.open( "clientwin.php", "myWindow", 
"status = 1, height = 300, width = 300, resizable = 0" )
}
//--&gt;
&lt;/script&gt;

i call above javascript in my submit button..

 &lt;input name="log" type="image"  id="log" value="Submit" src="index_files/login.png" onclick="myPopup2();"/&gt;

when i submit a login form then only that popup window open(if admin won't open)..

where i give that php code?

&lt;?php
if($u_role!='admin'){

echo '&lt;p&gt;&lt;a href="javascript:void(0);" onclick="PopupCenter(\\'forgot.php\\', \\'myPop1\\',400,200);"&gt;';

}
?&gt;

[ot]just an fyi:

Using the javascript protocol in the href of an <a> like you have is considered bad practice by many nowadays. The href is meant to be used to navigate to another web page not be used to run javascript.

A more acceptable way to use an <a> to execute javascript today is:

<a href='' onclick='doThis(); return false;'>Click me to run some javascript</a>

The return false; in the onclick stops the default action of the <a>, to go to the url in the href, after the javascript is run.

[/ot]