rebornishard Posted November 13, 2010 Share Posted November 13, 2010 i have homework about this but i don't know how to make it work, after a few hours it stuck with every login will go to same place i must create 4 id : 1.owner : can access all page , edit all id 2.chasier : report any item out, only access item out page (item.php) 3.warehouse : add item from purchasing department, add new item, get notification from chasier, tell purchasing department to buy item 4.purchasing department : get notification from warehouse, sent report to warehouse after add stock or add new item login.php <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="cek_login.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Login </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="username" type="text" id="username"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="password" type="text" id="password"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table> cek_login.php <?php $host="localhost"; $username="root"; $password=""; $db_name="shop_system"; $tbl_name="members"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $username=$_POST['username']; $password=$_POST['password']; $usertype=$_GET['usertype']; $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password' "; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ session_register("username"); session_register("password"); header("location:sukses.php"); } else { echo "Wrong Username or Password"; } ?> sukses.php <? session_start(); if(!session_is_registered(myusername)){ header("location:main_login.php"); } ?> <html> <body> Login Successful </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/218559-php-different-login-and-user-control/ Share on other sites More sharing options...
revraz Posted November 13, 2010 Share Posted November 13, 2010 My advice, be consisant with your code. Even small stuff like <? and <?php I cek_login.php, you are not setting your sessions correctly. In sukses.php, you are not referencing the same session name you are trying to use. Quote Link to comment https://forums.phpfreaks.com/topic/218559-php-different-login-and-user-control/#findComment-1133760 Share on other sites More sharing options...
rebornishard Posted November 13, 2010 Author Share Posted November 13, 2010 how to make that session corrrect hmmm make it <php? better that <? thanks for rep Quote Link to comment https://forums.phpfreaks.com/topic/218559-php-different-login-and-user-control/#findComment-1133830 Share on other sites More sharing options...
revraz Posted November 14, 2010 Share Posted November 14, 2010 <? is referred to as short tags. If a server does not have short tags enabled in their php.ini file, your code will not work. <?php would be preferred. In regards to sessions, I would recommend doing a quick session tutorial on the web, just do a google search there are a ton out there. Quote Link to comment https://forums.phpfreaks.com/topic/218559-php-different-login-and-user-control/#findComment-1133998 Share on other sites More sharing options...
rebornishard Posted November 15, 2010 Author Share Posted November 15, 2010 thanks for tell me different from <?php and <? pending, i will learn about session first, for temporary different page, i use location:$username.php Quote Link to comment https://forums.phpfreaks.com/topic/218559-php-different-login-and-user-control/#findComment-1134445 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.