Ryuujin Posted August 17, 2007 Share Posted August 17, 2007 I am coding my forums and I noticed if 2 people are using the forum at the same time when 1 posts it sometimes uses the other persons Session username... What am I doing wrong? If you need the code just ask. Quote Link to comment https://forums.phpfreaks.com/topic/65414-sessions-problem/ Share on other sites More sharing options...
supermerc Posted August 17, 2007 Share Posted August 17, 2007 Its hard to tell if we dont see code Quote Link to comment https://forums.phpfreaks.com/topic/65414-sessions-problem/#findComment-326649 Share on other sites More sharing options...
SirChick Posted August 17, 2007 Share Posted August 17, 2007 the code is quite important to view for fixing problems Quote Link to comment https://forums.phpfreaks.com/topic/65414-sessions-problem/#findComment-326650 Share on other sites More sharing options...
Ryuujin Posted August 17, 2007 Author Share Posted August 17, 2007 I belive this will give you what you need. if ($page == "Forum" && $section > "0") { echo "<h3 align='center'>Forums Topics</h3><br />"; echo "<table border='1' align='center'><tr><th>Topic Name</th><th>Last Post</th></tr>"; $result = mysql_query("SELECT * FROM forumtopics WHERE catparent=$section ORDER BY id DESC"); while($row = mysql_fetch_array($result)) { echo "<tr><td><a href=index.php?page=Forum§ion=$section&topicid=".$row['id'].">".$row['name']."</a></td><td>".$row['lastpost']."</td></tr>"; } echo "</table>"; echo "<center><a href=index.php?page=Forum§ion=$section&action=newtopic>Post a new Topic</a></center>"; } if ($page == "Forum" && $section > "0" && $action == "newtopic") { echo " <form action='index.php?page=Forum§ion=$section&action=postnewtopic' method='post'> <table><tr><td>Title: </td><td><input type='text' name='title' /></td></tr> <tr><td>Message: </td><td><textarea rows='20' cols='40' name='message'>Message Here</textarea></td></tr> <tr><td><input type='submit' value='Post Topic' /></td></tr></table> </form>"; } if ($page == "Forum" && $section > "0" && $action == "postnewtopic") { $poster = $_SESSION[username]; $name = mysql_real_escape_string($_POST[title]); $message = mysql_real_escape_string($_POST[message]); mysql_query("INSERT INTO forumtopics (catparent, name) VALUES ('$section', '$name')"); mysql_query("INSERT INTO forumposts (topicid2, poster, posterip, postedon, message, lastpost) VALUES ('$topicid','$poster', '$_SERVER[REMOTE_ADDR]', NOW(), '$message', NOW())"); echo "Topic Posted, <a href=index.php?page=Forum§ion=$section>Continue</a>"; } Quote Link to comment https://forums.phpfreaks.com/topic/65414-sessions-problem/#findComment-326660 Share on other sites More sharing options...
supermerc Posted August 17, 2007 Share Posted August 17, 2007 past ur login code too please Quote Link to comment https://forums.phpfreaks.com/topic/65414-sessions-problem/#findComment-326664 Share on other sites More sharing options...
Ryuujin Posted August 17, 2007 Author Share Posted August 17, 2007 if ($page == "Login") { echo "<center><h3>$page</h3></center>"; echo "<form action='index.php?page=Login&action=Check' method='post'>"; echo "<table align='center'><tr><td>Username: </td><td><input type='text' name='user' /></td></tr><br />"; echo "<tr><td>Password: </td><td><input type='password' name='pass' /></td></tr><br />"; echo "<table align='center'><tr><td><input type='submit' value='Login' /></td></tr></table>"; echo "</form>"; echo "<br />"; echo "<center><a href=index.php?page=Register>Register</a> || <a href=index.php?page=ForgotPassword>Forgot Password?</a></center>"; } if ($page == "Login" && $action == "Check") { $username = mysql_real_escape_string($_POST[user]); $password = mysql_real_escape_string($_POST[pass]); $passwordmd5 = md5($password); $sql="SELECT * FROM users WHERE username='$username' and password='$passwordmd5'"; $result = mysql_query($sql); $count = mysql_num_rows($result); if($count==1){ session_register("username"); session_register("userid"); echo "<center>Logged in Succesfully, <a href=index.php>Continue</a></center>"; } else { echo "<center>Wrong Username or Password</center>"; } } Quote Link to comment https://forums.phpfreaks.com/topic/65414-sessions-problem/#findComment-326674 Share on other sites More sharing options...
Ryuujin Posted August 17, 2007 Author Share Posted August 17, 2007 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/65414-sessions-problem/#findComment-326835 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.