shebbycs Posted November 24, 2011 Share Posted November 24, 2011 Login.php <?php session_start(); mysql_connect("localhost","root") or die(mysql_error()); mysql_select_db("cute") or die(mysql_error()); $username = $_POST['username']; $password = $_POST['pass']; if (isset($_POST["submit"])) { $log = "SELECT * FROM regis WHERE username = '$username'"; $login = mysql_query($log); $row = mysql_fetch_array($login); $number = mysql_num_rows($login); if ($number > 0) { $_SESSION['username'] = $row['username']; $_SESSION['userlevel'] = $row['userlevel']; if($_SESSION['userlevel']==1) { $_SESSION['is_logged_in'] == 1; header("Location: form2.php"); } else if($_SESSION['userlevel']== 0) { $_SESSION['is_logged_in'] == 1; header("Location: registration.php"); } } Registration.php <?php echo 'Welcome:' .$_SESSION['is_logged_in'];?> form2.php <?php session_start(); if (empty($_SESSION['is_logged_in'])) { header("Location:chatframe.php"); die(); // just to make sure no scripts execute } ?> <?php mysql_connect("localhost","root") or die(mysql_error()); mysql_select_db("cute") or die(mysql_error()); $message=$_POST['message']; $a=$_SESSION['username']; if(isset($_POST['submit'])) //if submit button push has been detected { if(strlen($message)>1) { $message=strip_tags($message); $IP=$_SERVER["REMOTE_ADDR"]; //grabs poster's IP $checkforbanned="SELECT IP from ipbans where IP='$IP'"; $checkforbanned2=mysql_query($checkforbanned) or die("Could not check for banned IPS"); if(mysql_num_rows($checkforbanned2)>0) //IP is in the banned list { print "You IP is banned from posting."; } else { $thedate = date("U"); //grab date and time of the post $insertmessage="INSERT into chatmessages (name,IP,postime,message) values('$a','$IP','$thedate','$message')"; mysql_query($insertmessage) or die("Could not insert message"); } } } ?> <html> <head> <script type="text/javascript"> function addsmiley(code) { var pretext = document.smile.message.value; this.code = code; document.smile.message.value = pretext + code; } function a() { var x = document.smile.message.value; if(x=="") { alert("Please insert an message!"); return false; } } </script> <style type="text/css"> body{ background-color: #d8da3d } </style> </head> <body> <form name="smile" method="post" action="form2.php" onSubmit="return a()" > Your message:<br><textarea name='message' cols='40' rows='2'></textarea><br> <img src="smile.gif" alt="" onClick="addsmiley('')" style="cursor:pointer;border:0" /> <img src="blush.gif" alt="" onClick="addsmiley('*blush*')" style="cursor:pointer;border:0" /> <input type='submit' name='submit' value='Send' class='biasa' ></form> <br> <br> </body> </html> In this registration.php when im called back its appear nothing im means the number is not showing and the login code even im had also put the "$_SESSION['is_logged_in'] == 1;" outside if else userlevel statement and then i put $d= $_SESSION['is_logged_in'] == 1; and im echoing back but it is nothing im thinks something wrong in session is login and also still it cannot redirect to admin -form2.php when session is login in is 1 Quote Link to comment https://forums.phpfreaks.com/topic/251737-how-to-make-the-session-login-both-user-and-admin-can-be-view/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 24, 2011 Share Posted November 24, 2011 The assignment operator is one = sign. The equal comparison operator is two == signs. If you are trying to assign a value to a variable, you use one = sign. Quote Link to comment https://forums.phpfreaks.com/topic/251737-how-to-make-the-session-login-both-user-and-admin-can-be-view/#findComment-1290966 Share on other sites More sharing options...
shebbycs Posted November 24, 2011 Author Share Posted November 24, 2011 The assignment operator is one = sign. The equal comparison operator is two == signs. If you are trying to assign a value to a variable, you use one = sign. yo means the session is login =1 is like this ??? Quote Link to comment https://forums.phpfreaks.com/topic/251737-how-to-make-the-session-login-both-user-and-admin-can-be-view/#findComment-1290968 Share on other sites More sharing options...
shebbycs Posted November 24, 2011 Author Share Posted November 24, 2011 problem solved thank you very much sir for make me more understanding bettwee assign variable actually me total confused when assign variable in if and assign variable to another variable tanks alot Quote Link to comment https://forums.phpfreaks.com/topic/251737-how-to-make-the-session-login-both-user-and-admin-can-be-view/#findComment-1290970 Share on other sites More sharing options...
Pikachu2000 Posted November 24, 2011 Share Posted November 24, 2011 How is this different from any of your other threads on this subject? Quote Link to comment https://forums.phpfreaks.com/topic/251737-how-to-make-the-session-login-both-user-and-admin-can-be-view/#findComment-1290971 Share on other sites More sharing options...
shebbycs Posted November 24, 2011 Author Share Posted November 24, 2011 How is this different from any of your other threads on this subject? not different but as im had modified it im put new thread and im sorry for the spam really actually first im din get the assign and im got confused and now only im got sir , if im spam im sorry Quote Link to comment https://forums.phpfreaks.com/topic/251737-how-to-make-the-session-login-both-user-and-admin-can-be-view/#findComment-1290974 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.