Jump to content

problem in implementing session


a65

Recommended Posts

i am trying to go to admin_control.php from login.php through session but it is showing the result improper access of page

 

html code is

<html><form method="post" action="login.php">

<link type="test/css" rel="stylesheet" href="user_info.css"></style>

<body><table border="1px">

<tr><td>username</td><td><input type=text name=myusername></td></tr>

<tr><td>password</td><td><input type=password name=mypassword></td>

<tr><td>type</td><td><select name=account_type>

<option>admin</option>

<option>normal</option></select></td></tr>

<tr><td><input type=submit name=login></td><td><input type=reset name=reset></td></tr></table></body></html>

 

php code is

 

<?php

session_start();

mysql_connect("localhost","root","");

mysql_select_db("bank_acount");

 

$var1=$_POST['myusername'];

$var2=$_POST['mypassword'];

$var3=$_POST['account_type'];

 

$query="select * from user_info where username='".$var1."' and password='".$var2."' and account_type='".$var3."'";

 

$result=mysql_query($query);

$row=mysql_fetch_assoc($result);

$num=mysql_num_rows($result);

 

$_SESSION['sname']=$row['username'];

$_SESSION['spasswword']=$row['password'];

$_SESSION['saccount_type']=$row['account_type'];

if($num)

{

if($_SESSION['saccount_type']==admin)

header("location:admin_control.php");

else

if($var3==normal)

{

header("location:user_control.php");

}

}

else

{

header("location:normal_user_reg.html");

}

 

?>

 

 

admin_contro.php is

 

 

<?php

session_start();

if(isset($_SESSION['sname']) && isset($_SESSION['spassword'])&& isset($_SESSION['saccount_type']) )

{

mysql_connect("localhost","root","");

mysql_select_db("bank_acount");

$query="select * from user_info";

$result=mysql_query($query);

 

?>

<div align="center"><table width="150px" border="1px"><tr><td bgcolor="red">admin_control</td></tr>

<tr><td><a href="add_account.php">add account</a></td></tr>

<tr><td><a href="allocate_amount.php">allocate amount</td></tr>

<tr><td><a href="make_payment.php"> make payment</a></td></tr>

<tr><td><a href="fund_transfer.php"> fund transfer</a></td></tr>

<tr><td><a href="set_user_type.php"> set user</a></td></tr>

 

</table></div>

<?php

}

else

echo("improper acccess of page");

?>

Edited by a65
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.