darkfreaks Posted February 7, 2008 Share Posted February 7, 2008 ok right now i have <?php if($age<18) {echo "You can not add this user nice try pedo";} ?> but i also want it to search membersprofile.php for the age and if the user that is posting to the underage user is above 18 to not allow them to add them as a friend. but i still want people who are under 17 to be able to add people who are the same age if not less. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 7, 2008 Share Posted February 7, 2008 So what's the problem? What have you tried? What did or didn't work? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted February 7, 2008 Author Share Posted February 7, 2008 oh it worked ruport but now im getting complaints about other people who are under 18 not being able to add other people who are under 18. it needs modding and idk how to do it. Quote Link to comment Share on other sites More sharing options...
Moon-Man.net Posted February 7, 2008 Share Posted February 7, 2008 We need some code of somesort to help you. Where is the code that you use to check if they are under 18? You will need 2 variables, one of the logged in user ($user_age) and one of the user you are trying to message/add/whatever ($target_age) then base your if statement off that Need some code to help. What variables do you have to work with? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted February 7, 2008 Author Share Posted February 7, 2008 Code: <?php $strTitle = 'You are now friends'; define('QUADODO_IN_SYSTEM', true); require_once('includes/header2.php'); $with = $qls->Security->make_safe($_POST['with']); $username = $qls->Security->make_safe($_POST['username']); include ('config.php'); $result = $qls->SQL->select('*', 'friends', array('username' => array( '=', $username ) ) ); $already_friends = false; while ($row = $qls->SQL->fetch_array($result)) { if ($row['with'] == $with) { $already_friends = true; } } if($age<18){echo "You can't add a user under 18 for legal reasons!";} if ($already_friends === true) { echo 'You are already friends with ' . $with; } else { // My insert query faster and handles errors $qls->SQL->insert('friends', array( 'username', 'with' ), array( $username, $with ) ); echo "You are now friends with <a href=\"../profile/$with\">$with</a>"; } include ('includes/footer.php'); ?> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted February 7, 2008 Author Share Posted February 7, 2008 ok so i tried <?php $users_age=strpos('profile.php',$age); if($age<18||$users_age>18) {echo "You can't add a user under 18 for legal reasons!";}?> still no luck ??? Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 7, 2008 Share Posted February 7, 2008 $users_age=strpos('profile.php',$age); if($age<18||$users_age>18) If profile.php is a script, it's very likely not going to have a user's age embedded within it. Anyways, you're telling PHP to look for whatever is in $age within the string 'profile.php'. In all likelihood you want to pull each person's age from the database and compare them, and that is only if they are not contained within memory already. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted February 7, 2008 Author Share Posted February 7, 2008 how would i find the difference with just the age variable? ??? Quote Link to comment Share on other sites More sharing options...
helraizer Posted February 7, 2008 Share Posted February 7, 2008 how would i find the difference with just the age variable? ??? Say you had a database with all users in it, you'd have username, name, surname, title etc.. you'd also have an age column. Then pull from the database the age from the person doing the adding (user1) and that of the person being added (user2). So something like if($user1_age>18 && $user2_age<18) { echo "You can't add a user under 18 for legal reasons!"; } Something like that. Although, you might want to refine your ages.. at the moment a 19 year old can't add a 17 year old. That's not anything dodgy at all. and it limits people. this if($user1_age>25 && $user2_age<16) { echo "You can't add a user under 16 for legal reasons!"; } would probably be better. Sam Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.