Jump to content

php if statment


Jiraiya

Recommended Posts

i have a script that allows users to view other members profiles but im not sure how to create a script that  checks if the target profile has there profile variable set to "public" so i need it to check if the target profile's user has there "profile" variable set to "public" and if it is set to public continue to run the script to view the profile but if it he "profile" variable is set to anything but "public" it redirects the user trying to view the profile to another page

Link to comment
Share on other sites

<?php 

$q = "SELECT view FROM profiles WHERE username='{$_POST['username']}' LIMIT 1";
$query = mysql_query($q) or die(mysql_error());
$row = mysql_fetch_assoc($query);

if($row['view'] == "private") {
echo "This profile is set to private, redirecting you. <meta http-equiv=\"refresh\" content=\"3;url=index.php\" />"; }

else { //display profile }

?>

 

That's a rough idea, I'd highly recommend escaping posted data rather than using it directly in a query at the least.

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.