Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7408113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:51:13+00:00 2026-05-29T05:51:13+00:00

ok can anyone see what im doing wrong here? just incase my coding is

  • 0

ok can anyone see what im doing wrong here? just incase my coding is crap lol. what i have is a members website, the links are made based on wether the user is logged in or not. what im actually trying to achieve is getting the profile link to change by checking what account type the user has chosen at sign up

ive been at this for absolutely hours and im not sure what else i can try, im sure im on the right track but my php skills leave a lot to be desired

anyway heres my code and if anyone can help i would be eternally greatful, forgot what im trying to pass is $logOptions_account to achieve the link and the accounttype field in the database is the enum type if it makes a difference

<?php
/* 
 * Date: january 20, 2012
   *------------------------------------------------------------------------------------------------*/
session_start(); // Start Session First Thing
// Force script errors and warnings to show on page in case php.ini file is set to not display them
error_reporting(E_ALL);
ini_set('display_errors', '1');
//-----------------------------------------------------------------------------------------------------------------------------------
include_once "scripts/connect_to_mysql.php"; // Connect to the database
$dyn_www = $_SERVER['HTTP_HOST']; // Dynamic www.domainName available now to you in all of your scripts that include this file
//------ CHECK IF THE USER IS LOGGED IN OR NOT AND GIVE APPROPRIATE OUTPUT -------
$logOptions = ''; // Initialize the logOptions variable that gets printed to the page
// If the session variable and cookie variable are not set this code runs
if (!isset($_SESSION['idx'])) { 
  if (!isset($_COOKIE['idCookie'])) {
     $logOptions = '<a href="//' . $dyn_www . '/register.php">Register Account</a>
 &nbsp;&nbsp; | &nbsp;&nbsp; 
 <a href="http://' . $dyn_www . '/login.php">Log In</a>';
   }
}
// If session ID is set for logged in user without cookies remember me feature set
if (isset($_SESSION['idx'])) { 

$decryptedID = base64_decode($_SESSION['idx']);
$id_array = explode("p3h9xfn8sq03hs2234", $decryptedID);
$logOptions_id = $id_array[1];
$logOptions_username = $_SESSION['username'];
$logOptions_username = substr('' . $logOptions_username . '', 0, 15); // cut user name down in length if too long

// Check if this user has any new PMs and construct which envelope to show
$sql_pm_check = mysql_query("SELECT id FROM private_messages WHERE to_id='$logOptions_id' AND opened='0' LIMIT 1");
$num_new_pm = mysql_num_rows($sql_pm_check);
if ($num_new_pm > 0) {
    $PM_envelope = '<a href="pm_inbox.php"><img src="images/pm2.gif" width="18" height="11" alt="PM" border="0"/></a>';
} else {
    $PM_envelope = '<a href="pm_inbox.php"><img src="images/pm1.gif" width="18" height="11" alt="PM" border="0"/></a>';
}
// Ready the output for this logged in user
$act = "";
$logOptions_account = $act;
$act = mysql_query("SELECT accounttype FROM memberstable WHERE accounttype='$logOptions_account' ");
if ($act == "a") {
    $logOptions_account = '<a href="fanprofile.php">';}
    else if($act == "b") {
    $logOptions_account = '<a href="artistprofile.php">';}
    else if($act == "c") {
    $logOptions_account = '<a href="bandprofile.php">';}
    else if($act == "d") {
    $logOptions_account = '<a href="businssprofile.php">';}
    else if($act == "e") {
    $logOptions_account = '<a href="venueprofile.php">';}
    else if($act == "f") {
    $logOptions_account = '<a href="serviceprofile.php">';}
    else {
    }



$logOptions = $PM_envelope . ' &nbsp; &nbsp;
<a href="http://' . $dyn_www . '">Home</a>
&nbsp;&nbsp; |&nbsp;&nbsp; 
<a href="http://' . $dyn_www . '/' . $logOptions_account . '?id=' . $logOptions_id . '">Profile</a>
&nbsp;&nbsp; |&nbsp;&nbsp;
<div class="dc">
<a href="#" onclick="return false">Account &nbsp; <img src="images/darr.gif" width="10" height="5" alt="Account Options" border="0"/></a>
 <ul>
<li><a href="http://' . $dyn_www . '/edit_profile.php">Account Options</a></li>
<li><a href="http://' . $dyn_www . '/pm_inbox.php">Inbox Messages</a></li>
<li><a href="http://' . $dyn_www . '/pm_sentbox.php">Sent Messages</a></li>
<li><a href="http://' . $dyn_www . '/logout.php">Log Out</a></li>

</ul>
</div>
';

} else if (isset($_COOKIE['idCookie'])) {// If id cookie is set, but no session ID is set yet, we set it below and update stuff

$decryptedID = base64_decode($_COOKIE['idCookie']);
$id_array = explode("nm2c0c4y3dn3727553", $decryptedID);
$userID = $id_array[1]; 
$userPass = $_COOKIE['passCookie'];
// Get their user first name to set into session var
$sql_uname = mysql_query("SELECT firstname, lastname, email, accounttype FROM memberstable WHERE id='$userID' AND password='$userPass' LIMIT 1");
$numRows = mysql_num_rows($sql_uname);
if ($numRows == 0) {
    // Kill their cookies and send them back to homepage if they have cookie set but are not a member any longer
    setcookie("idCookie", '', time()-42000, '/');
    setcookie("passCookie", '', time()-42000, '/');
    header("location: index.php"); // << makes the script send them to any page we set
    exit();
}
while($row = mysql_fetch_array($sql_uname)){ 
    $firstname = $row["firstname"];
    $surname = $row["lastname"];
    $useremail = $row["email"];
    $logOptions_account = $row["accounttype"];
}

$_SESSION['id'] = $userID; // now add the value we need to the session variable
$_SESSION['idx'] = base64_encode("g4p3h9xfn8sq03hs2234$userID");
$_SESSION['firstname'] = $firstname;
$_SESSION['surname'] = $surname;
$_SESSION['useremail'] = $useremail;
$_SESSION['userpass'] = $userPass;

$logOptions_id = $userID;
$logOptions_uname = $firstname;
$logOptions_uname = $surname;
$logOptions_uname = substr('' . $logOptions_uname . '', 0, 15); 
///////////          Update Last Login Date Field       /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
mysql_query("UPDATE memberstable SET last_log_in=now() WHERE id='$logOptions_id'"); 
// Ready the output for this logged in user
// Check if this user has any new PMs and construct which envelope to show
$sql_pm_check = mysql_query("SELECT id FROM private_messages WHERE to_id='$logOptions_id' AND opened='0' LIMIT 1");
$num_new_pm = mysql_num_rows($sql_pm_check);
if ($num_new_pm > 0) {
    $PM_envelope = '<a href="pm_inbox.php"><img src="images/pm2.gif" width="18" height="11" alt="PM" border="0"/></a>';
} else {
    $PM_envelope = '<a href="pm_inbox.php"><img src="images/pm1.gif" width="18" height="11" alt="PM" border="0"/></a>';
}
// Ready the output for this logged in user
 $act = "";
$logOptions_account = $act;
$act = mysql_query("SELECT accounttype FROM memberstable WHERE accounttype='$logOptions_account' LIMIT 1");
if ($act == 'a') {
    $logOptions_account = '<a href="fanprofile.php">';}
    else if($act == 'b') {
    $logOptions_account = '<a href="artistprofile.php">';}
    else if($act == 'c') {
    $logOptions_account = '<a href="bandprofile.php">';}
    else if($act == 'd') {
    $logOptions_account = '<a href="businssprofile.php">';}
    else if($act == 'e') {
    $logOptions_account = '<a href="venueprofile.php">';}
    else if($act == 'f') {
    $logOptions_account = '<a href="serviceprofile.php">';}
    else {
    }
 $logOptions = $PM_envelope . ' &nbsp; &nbsp;
 <!--<a href="http://' . $dyn_www . '">Home</a>
&nbsp;&nbsp; |&nbsp;&nbsp; -->
 <a href="http://' . $dyn_www . '/' . $logOptions_account . '?id=' . $logOptions_id . '">Profile</a>
&nbsp;&nbsp; |&nbsp;&nbsp;
<div class="dc">
<a href="#" onclick="return false">Account &nbsp; <img src="../images/darr.gif" width="10" height="5" alt="Account Options" border="0"/></a>
<ul>
<li><a href="http://' . $dyn_www . '/edit_profile.php">Account Options</a></li>
<li><a href="http://' . $dyn_www . '/pm_inbox.php">Inbox Messages</a></li>
<li><a href="http://' . $dyn_www . '/pm_sentbox.php">Sent Messages</a></li>
<li><a href="http://' . $dyn_www . '/logout.php">Log Out</a></li>
</ul>
</div>';
}



?>

i am really sorry if im doing something wrong or dumb here but im blind now from looking at this all day and as i said i would be eternally greatful if someone can help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:51:14+00:00Added an answer on May 29, 2026 at 5:51 am

    This is complete nonsense:

    $act = ""; // is empty
    $logOptions_account = $act; // both are empty
    $act = mysql_query("SELECT accounttype FROM memberstable WHERE accounttype='$logOptions_account' "); // why you query for $logOptions_account(=$act) only to get $act again?
    if ($act == "a") { // it is still empty, not "a"
    

    And to get a row finally:

    // make sure, that $logOptions_account has a valid value
    $result = mysql_query("SELECT accounttype FROM memberstable WHERE accounttype='$logOptions_account' ");
    if (!$result) {
        echo 'Could not run query: ' . mysql_error();
    }
    else {
      $row = mysql_fetch_row($result);
      if ($row['accounttype'] == "a") { ... }
      elseif ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone see what Im doing wrong here? I know it is a lot
Does anyone have experience using the URL Rewrite Module (see here )? Can it
Can anyone see anything wrong with this login script: public function login($username, $pass, $remember)
I'm at my wit's end with this. Can anyone see anything wrong with this
Trying to convert the following but am having difficulty. Can anyone see where I'm
Does anyone know how I can check to see if a directory is writeable
I would like to see if anyone can offer any advise on furthering my
Rails noob here so I'm not sure what I'm doing wrong. We're replacing a
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can anyone tell me how I can display a status message like 12 seconds

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.