Jump to content

I can't figure it out!


Jayden_Blade
Go to solution Solved by QuickOldCar,

Recommended Posts

I am trying to view a different users profile. I am able to view mine. I did this 2 years ago.... I cant remember. Here is my php code. What do i have to put in url to see others profile?

<?php

/* DONE DONE DONE DONE DONE DONE DONE
* How to display profile page.
* Check if the user is viewing ANOTHER user's profile
* and if so, display that profile, otherwise display the
* user's own profile
*/

session_start();
if (!$_SESSION || !$_SESSION['login']) {
 //redirect to a login page
 header('Location: index.php');
 
  exit;
}

//echo $username;
//echo $userid;
error_reporting(E_ALL);
include ('database.php');
//Get userid that matches username in table to username in url
//$exists = mysql_query("SELECT `username` FROM `user` WHERE `username`='$_GET[user]' LIMIT 1");
//$exists1 = mysql_fetch_assoc($exists);
	
	
if ($_GET){
$result = mysql_query("SELECT `userid` FROM `user` WHERE `username`='$_GET[user]' LIMIT 1");

//returns the results from the mysql database in an associative array format
$profileusername = mysql_fetch_assoc($result);
// RE assigns $profileusername value to $profileID
$profileID = $profileusername['userid'];
//assigns $_GET username to $username
$username = $_GET['user'];
//}
//elseif($username === $exists1);{	


$resulta = mysql_query("SELECT `age`,`sex`,`sexpref`,`maritalstatus`,`location`,`lookingfor`,`children`,`smoking`,`drinking`,`lastlog`,`profileimagelocation` FROM `profiledata` WHERE `user`='$_GET[user]' LIMIT 1");
$userstats = mysql_fetch_array($resulta);
$age = $userstats['age'];
$sex = $userstats['sex'];
$sexpref = $userstats['sexpref'];
$maritalstatus = $userstats['maritalstatus'];
$location = $userstats['location'];
$lookingfor = $userstats['lookingfor'];
$children = $userstats['children'];
$smoking = $userstats['smoking'];
$drinking = $userstats['drinking'];
$lastlog = $userstats['lastlog'];
$profileimage = $userstats['profileimagelocation'];
//echo $age;

$resultb = mysql_query("SELECT `interests` FROM `interests` WHERE `user`='$_GET[user]' LIMIT 1");
$userinterests = mysql_fetch_array($resultb);
$interests = $userinterests['interests'];
//echo $interests;

$resultc = mysql_query("SELECT `aboutme` FROM `aboutme` WHERE `user`='$_GET[user]' LIMIT 1");
$useraboutme = mysql_fetch_array($resultc);
$aboutme = $useraboutme['aboutme'];
//echo $aboutme;


$resultd = mysql_query("SELECT `fetishes` FROM `fetishes` WHERE `user`='$_GET[user]' LIMIT 1");
$userfetishes = mysql_fetch_array($resultd);
$fetishes = $userfetishes['fetishes'];
//echo $fetishes;

//removes the resource and frees the database so it doesn't consume extra memory
mysql_free_result($result);
mysql_free_result($resulta);
mysql_free_result($resultb);
mysql_free_result($resultc);
mysql_free_result($resultd);



}

else
{

ini_set('display_errors',1); 
 error_reporting(E_ALL);

//Get userid from the users table where the username matches the session username 

$result = mysql_query("SELECT `userid` FROM `user` WHERE `username`='$_SESSION[username]' LIMIT 1") or die("query failed 1".mysql_error());
//returns the results from the mysql database in an associative array format
$profileusername = mysql_fetch_assoc($result);
// RE assigns $profileusername value to $profileID
$profileID = $profileusername['userid'];
$username = $_SESSION['username'];
//echo $username;
//echo $profileID;

$resulta = mysql_query("SELECT `age`,`sex`,`sexpref`,`maritalstatus`,`location`,`lookingfor`,`children`,`smoking`,`drinking`,`lastlog`,`profileimagelocation` FROM `profiledata` WHERE `username`='$_SESSION[username]'") or die("query failed 2".mysql_error());
$userstats = mysql_fetch_array($resulta);
$age = $userstats['age'];
$sex = $userstats['sex'];
$sexpref = $userstats['sexpref'];
$maritalstatus = $userstats['maritalstatus'];
$location = $userstats['location'];
$lookingfor = $userstats['lookingfor'];
$children = $userstats['children'];
$smoking = $userstats['smoking'];
$drinking = $userstats['drinking'];
$lastlog = $userstats['lastlog'];
$profileimage = $userstats['profileimagelocation'];
//echo $age;

$resultb = mysql_query("SELECT `interests` FROM `interests` WHERE `username`='$_SESSION[username]'") or die("query failed 3".mysql_error());
$userinterests = mysql_fetch_array($resultb);
$interests = $userinterests['interests'];
//echo $interests;

$resultc = mysql_query("SELECT `aboutme` FROM `aboutme` WHERE `username`='$_SESSION[username]'") or die("query failed 4".mysql_error());
$useraboutme = mysql_fetch_array($resultc);
$aboutme = $useraboutme['aboutme'];

$resultd = mysql_query("SELECT `fetishes` FROM `fetishes` WHERE `username`='$_SESSION[username]'") or die("query failed 5".mysql_error());
$userfetishes = mysql_fetch_array($resultd);
$fetishes = $userfetishes['fetishes'];
//echo $fetishes;

//removes the resource and frees the database so it doesn't consume extra memory
mysql_free_result($result);
mysql_free_result($resulta);
mysql_free_result($resultb);
mysql_free_result($resultc);
mysql_free_result($resultd);




}
?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.