February 16, 201214 yr Hello all My next query is regarding user interaction on profile pages. I want to be able to have only logged in users be able to write a comment on someones profile. I dont require the "like" or comment back feature just a simple message. But i dont want none logged in users to be able to leave messages Help or suggestions welcomed. Thanks again
February 16, 201214 yr Hello all My next query is regarding user interaction on profile pages. I want to be able to have only logged in users be able to write a comment on someones profile. I dont require the "like" or comment back feature just a simple message. But i dont want none logged in users to be able to leave messages Help or suggestions welcomed. Thanks again Couple of ways... 1. Prevent the user being able to see the textarea and submit button. <?php if (isset($_SESSION['UserID'])) { // form goes here } ?> 2. Prevent the user being able to post even if they manage to get around using your form <?php if (!isset($_SESSION['UserID'])) { header('location: /'); } ?> You'll see it's almost the same code, one checks to see if the user IS logged in, the other checks to see if the user ISN'T logged in. You could also use SQL Joins. Edited February 16, 201214 yr by adamsmith
Create an account or sign in to comment