Jump to content


  • Posts

  • Joined

  • Last visited

Nematode128's Achievements


Member (2/5)



  1. "www." was never added into my address bar so I was a little confused when I saw the second sessid have the domain with "www." in front of it. I fixed my links and that seems to have fixed the issue. Thanks for your help. I appreciate it!
  2. Would I benefit from turning output buffering on? And, this might be a stretch, but could it be my links that are causing issues? I ask because I had this and whenever I clicked that link the page would "break" echo "<a href='http://pereia.net/Dev/mail/view/inbox'>Back to Inbox</a>"; I changed it to echo "<a href='javascript:history.back()'>Back to Inbox</a>"; And that works perfectly fine.
  3. No I've tried them with just the regular .php file extension (ex. page.php?act=view) with the same result as it showing the page as if the user wasn't logged in. Output_buffering has no value according to phpinfo(). What would be discouraged .ini settings? I don't remember ever changing anything in a .ini file .. All the pages giving me issues so far are in a /mail directoy(I'm working on a private message feature). As far as the session goes, it starts out with sitename.net as the domain, Session as the Expiration and "/" as the path then when I click a link with a clean url it adds another phpsessid with www.sitename.net as the domain and it's either on that page that creates the second phpsessid that it says the user is logged out or it logs the user out on the next link I click.
  4. Ya it's always the same pages. It doesn't change if I refresh the broken page, still shows as if I were logged out. That is the real code for displaying the session in the header file. It's displayed in a bootstrap nav bar so the only other code around it is html. I noticed on the broken pages the value for "phpsessid" changes, why is that? And yeah I have it logging warnings and notices
  5. Not if I actively refresh but I go idle for x amount of time then they session logs me out. How would I make sure the correct session identifier is being sent? Nothing in the error log
  6. I've been using clean URLs and it's been giving my PHP sessions for my user system some trouble. I display the logged in users username on every page via a header.php file that I require on every page. Sometimes when I click a link to navigate to a page with a clean URL, the session information "disappears" and asks the user to login but if I navigate to another page from the clean url that the session "disappeared" on, the logged in users username is displayed at the top of the page like normal. Any idea certain pages cause the session to "disappear" Header.php where the user info is displayed. $_SESSION['username'] is set on the login page <? session_start(); if (isset($_SESSION['username'])) { echo "Welcome back, " . $_SESSION['username']; } ?>
  7. Gotcha that seems to have fixed it. Thanks!
  8. I printed out page with what I currently have and it printed just "i" I'm really new to HT access so can you provide some references on how I'd rewrite it? I followed this tutorial: https://www.youtube.com/watch?v=zJxCq6D14eM and from the way they made it sound view/inbox should have been processed like view.php?page=inbox based off the example they used
  9. My php is something like this to display the inbox <?php $page = $_GET['page']; if ($page == 'inbox') { echo "Inbox"; } ?>
  10. I've been messing around with clean urls in php and I've been having some trouble. I'm working on a private messaging system and when I go to "sitename.com/mail/view.php?page=inbox" it correctly displays the users inbox messages but when I put "sitename.com/mail/view/inbox/" it just displays the page like the GET value isn't set. Why is that? this is the HTACCESS file for clean url RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^view/([a-z]) view.php?page=$1 [NC,L]
  11. Gotcha, that makes sense. Thank you. I'm having trouble using fetch array in this other function though. This function will be to show the user notifications however fetch array is giving me this error: "Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_array() in /home/evoarena/public_html/Dev/functions.php:69 Stack trace: #0 /home/evoarena/public_html/Dev/index.php(5): notifications(Object(mysqli)) #1 {main} thrown in /home/evoarena/public_html/Dev/functions.php on line 69" where line 69 is $news_user = $news_stmt->fetch_array(); The functions are basically copy and pasted with variables and th query changed as needed so why does this function provide me with a fetch array error? function notifications($link) { if (isset($_SESSION['username'])) { $news_query = "SELECT news_read FROM users WHERE username=?"; if ($news_stmt = $link->prepare($news_query)) { $username = $_SESSION['username']; $news_stmt->bind_param("s", $username); $news_stmt->execute(); $news_result = $news_stmt->get_result(); $news_user = $news_stmt->fetch_array(); if ($news_user['news_read'] == '0') { echo "<div class='alert alert-primary alert-dismissible' role='alert'> <center><button type='button' class='close' data-dismiss='alert'>&times;</button>There is a new post on the <a href='http://www.pereia.net/Dev/news/index.php'>Updates</a> page </center></div>"; } } else { $error = $link->errno . ' ' . $link->error; echo $error; } } }
  12. So I'd just want this? function egg_received($link) { //contents } or would I need to add more code inside the actual function
  13. I'm trying to use a prepared statement inside a function and it's giving me some trouble. I have an RPG game I'm working on an want a function to include on pages that tells a user to collect their egg from the professor if they haven't already received it yet. When I try to call the function on the page these are the errors I get: Notice: Undefined variable: link in /home/evoarena/public_html/Dev/functions.php on line 23 Fatal error: Uncaught Error: Call to a member function prepare() on null in /home/evoarena/public_html/Dev/functions.php:23 Stack trace: #0 /home/evoarena/public_html/Dev/login.php(59): egg_received() #1 {main} thrown in /home/evoarena/public_html/Dev/functions.php on line 23 $link is defined in a db config file and on the page I'm trying to call the function I have the files required like this so I'm wondering why it still thinks link is an undefined variable require "config.php"; require "functions.php"; Function Code: function egg_received () { if (isset($_SESSION['username'])) { $username = $_SESSION['username']; $query = "SELECT egg_received FROM users WHERE username=?"; if ($stmt = $link->prepare($query)) { $stmt->bind_param("s", $username); $stmt->execute(); $result = $stmt->get_result(); $egg = $result->fetch_array(); if ($egg['egg_received'] == '0') { echo "<div class='alert alert-primary' role='alert'> Oh well hello there! It appears the professor is looking for you today!<br><a href='../world/professor.php'>Visit the Professor</a> </div>"; require "footer.php"; exit; } } else { $error = $link->errno . ' ' . $link->error; echo $error; } } }
  • 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.