Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
My login system causes a Post Not Found on homepage

 
Reply to topic    Forum Index » Help View previous topic
View next topic
My login system causes a Post Not Found on homepage
Author Message
Douglas



Joined: 09 Jun 2008
Posts: 12

Post My login system causes a Post Not Found on homepage Reply with quote
I have a rather weird problem on my website. I've placed a membersystem on my site, which has a login that changes in a menu when one's logged in. I also placed this login on the index of my page, which also has the CNR script on it (latest news, headlines..). The problem is that WHEN you're logged in in my membersystem, the place where the CNR news shows up, disappears, only showing the text "Post Not Found", and this only happens when i'm logged in. When i'm not, the news just appears normaly and my login form shows up normal (Username, Password). What could be the problem, and how can I solve this?

For interrest, I've added my login code:
Code:
<?php
session_start(); //allows session
include "config.php";

if($logged[id]) {
//welcomes the member
echo "Welcome $logged[username]<br><br>";
//shows the user menu
$new = mysql_query("select * from pmessages where unread = 'unread' and touser = '$logged[username]'");
$new = mysql_num_rows($new);
echo "
- <a href='members.php'>Members</a><br>
- <a href='editprofile.php'>Edit Profile</a><br> 
- <a href='messages.php'>Private Messages ($new New)</a><br>
- <a href='newfriends.php'>Friend Requests</a><br>
- <a href='changepassword.php'>Change Password</a><br>
- <a href='logout.php?logout'>Logout</a>";
}else
//if there trying to login
if(isset($_GET['login'])) {
//removes sql injections from the data
$username= htmlspecialchars(addslashes($_POST[username])); 
//encrypts the password
$password = sha1(md5(md5(sha1(md5(sha1(sha1(md5($_POST[password]))))))));
//gets the username data from the members database
$uinfo = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error()); 
//see if the user exists
$checkuser = mysql_num_rows($uinfo);
//if user name not found in database error
if($checkuser == '0')
{
echo "Username not found";
}else{
//fetch the sql
$udata = mysql_fetch_array($uinfo);
//checks see if the account is verified
if($udata[userlevel] == 1) { 
echo "This account had not been verified.";
}
//if it is continue
else
//if the db password and the logged in password are the same login
if($udata[password] == $password) {
$query = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error()); 
//fetchs the sql
$user = mysql_fetch_array($query);
$last_date = date("l, F j, Y h:i A");
$update = mysql_query("UPDATE `members` SET `last_seen` = '$last_date' WHERE `username` = '$user[username]' AND `id` = '$user[id]';") or die(mysql_error());
//sets the logged session
$_SESSION['id'] = "$user[id]";
$_SESSION['password'] = "$user[password]";

echo "You are now logged in, Please wait. . .";
//redirects them
echo "<meta http-equiv='Refresh' content='2; URL=welcome.php'/>";
}
//wrong password
else{
echo "Incorrect username or password!"; 
}
}
}else{
//If not the above show the login form
echo "<form action='login.php?login' method='post'>
<table width='200'>
  <tr>
    <td width='120'>Username:</td>
    <td width='180'><input type='text' name='username' size='17' maxlength='50'></td>
  </tr>
  <tr>
    <td>Password:</td>
    <td><input type='password' name='password' size='17' maxlength='50'></td>
  </tr>
    <tr>
    <td colspan='2'><input type='submit' value='Login'></td>
  </tr>
</table>
</form>
<a href='register.php'>Register to DE!</a> <strong>::</strong> <a href='forgotpass.php'>Forgot Password</a>";
}
?>


And the code to display news is just normal, like this:
Code:
<?php
$category = "1";
$number = 7;
$template = "Default";
include("news/show_news.php"); 
?>


Suprisingly enough, it does show the full news, say; i click Read More and get to the page which views the full news (view.php), without being logged in first, but logging in while in view.php, and go back to this page after logging in.

I hope you'll understand my problem Embarassed
Tue Sep 16, 2008 10:25 pm View user's profile Send private message
Guest








Please login to hide the ads.

Partyism



Joined: 25 Sep 2007
Posts: 301

Post Reply with quote
i think its because your membersystem and cutenewsru are using the same names in the database.
That is causing the post not found i guess. I had it with my phpbb3 forum tracker..
Wed Sep 17, 2008 8:00 am View user's profile Send private message
Douglas



Joined: 09 Jun 2008
Posts: 12

Post Reply with quote
And you solved the problem by giving one of them a new database name?

EDIT: I checked my database for CNR, and saw that it uses the same field as my membersystem: username.
but what can i do about this? Sad I've worked hard on futher-editing my membersystem (i've got it from an online tutorial).
Wed Sep 17, 2008 1:29 pm View user's profile Send private message
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2857
Location: Germany

Post Reply with quote
The variable $_SESSION['id'] might be the problem:
Code:
$_SESSION['id'] = "$user[id]";


Try to rename it to somethink like $_SESSION['user_id'].
Thu Sep 18, 2008 6:25 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    Forum Index » Help All times are GMT + 1 Hour
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum



Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Music Lyrics.