Note that there are some explanatory texts on larger screens.

plurals
  1. POErrors for changing variables content depending on session status
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/5291527/errors-for-changing-variables-content-depending-on-session-status">Errors for changing variables content depending on session status</a> </p> </blockquote> <p>Hello! I am trying to write a script that changes a veriables content depending on there session status and what ID that was in the URL of the page (e.g www.example.com/profile.php?id=1) so it would display one set of content if they arnt logged in and viewing someone elses profile, another if there logged in and on there own profile, and another if there logged in and viewing someone elses profile.</p> <p>Firstly the script gets the ID from the url:</p> <pre><code> if(isset($_GET['id'])) { $id = preg_replace('#[^0-9]#i', '', $_GET['id']); // filter everything but numbers } else if (isset($_SESSION['idx'])) { $id = $logOptions_id; } else { header("location: index.php"); exit(); } </code></pre> <p>Then it runs some other code i wont include, then this code:</p> <pre><code>// ------- DECIDES WHAT TO DISPLAY, DEPENDING ON SESSION--------- if (isset($_SESSION['idx']) &amp;&amp; $logOptions_id == $id) { // If session is set and ID matches the profiles ID $content = ""Your viewing your own profile"; } else if (isset($_SESSION['idx']) &amp;&amp; $logOptions_id != $id) { // If SESSION is set, but ID dosent match profiles ID $follow_option = "Your viewing someone elses profile"; } else { $content = "Your are not logged in"; } // ------- END DECIDES WHAT TO DISPLAY, DEPENDING ON SESSION--------- print $content; </code></pre> <p>Now to my problem, all it does is display the option for being logged in and viewing someone elses profile "Your viewing someone elses profile". If you see any errors that would lead to this, please answer below. Thanks! :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload