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
https://forums.phpfreaks.com/topic/140528-php-if-statment/
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
https://forums.phpfreaks.com/topic/140528-php-if-statment/#findComment-735399
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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