4

In php how would I "visit" another user cause a lot of people say use

$_SESSION["username"] = $_POST["username"]

or

Echo $_SESSION["username"]

Or

Echo $_POST["USERNAME"]

Are any of these good or should I just feck the computer out the window 😂

Comments
  • 2
    I believe post variables are deleted on the second page load, so if this it's a one-time thing it'd be fine but guessing by the fact that you're using session variables in the first place, I'd wager you want to use them
  • 1
    @theNSA thanks for the tip, no I haven't started anything yet, just wanted some tips before I started it.
  • 0
    Could you explain your case?
  • 1
    In the first example you assign the value of the POST variable to the SESSION variable, which are super-globals in PHP (you might check this term out).
    Echo prints the value of a variable in the browser. You can also use var_dump(), especially for showing the content of an array.
  • 0
    @ScriptCoded when ever im on my page lets say, I see my stuff but when I click a users profile it still just shows my things. I seen a youtube video and he said use fetch_assoc and row? Would he be right if I want to visit another users profile and see their info
  • 1
    @htmljoecss Everything with session is wrong in this case. You'll have to get the user from the database using $_POST['username']
  • 1
    @ScriptCoded So what method do you think I should use :) for e.g echo $_POST["WHATEVER"]; ?? Sorry haha such a newbie
  • 0
    @htmljoecss You have a database, right?
  • 1
  • 0
    @htmljoecss What driver are you using?
  • 1
    @ScriptCoded uber! Hah Wamp, only doing localhost for now cause I have piss all done
  • 0
    @htmljoecss ... What database driver are you using? Mysqli I'm guessing?
  • 1
  • 0
    @htmljoecss Would you mind sharing your code perhaps?
Add Comment