Jump to content

stewart715

Members
  • Posts

    58
  • Joined

  • Last visited

    Never

Everything posted by stewart715

  1. http://www.phpfreaks.com/tutorials/40/0.php
  2. I can't seem to figure this out whatsoever! Any help will be much appreciated. To explain best, I'll show you the database tables I have for example purposes lets say $user->uid is 2 TABLE: buddylist [b]uid  buddy  received[/b] 2      7          1 3      5          1 2      8          0 2      3          1 TABLE: users [b]uid  name[/b] 2    mike 7      joe 3    john 8      bill i need a code that will select buddy from buddylist where $user->uid = uid and receieved = 1 and then check users where the outputted buddy number = uid (in users) then to output the name.. so joe and john should come out..it will see that $user->uid (2) has 7 and 3 next to it in buddy where recieved is 1...then it will find that persons name by comparing 7 and 3  to uid in users and then ouput joe and john..im guessing its an innerjoin? Thanks for ANY help!
  3. Thank's so much for any help you can offer. Let me tell you what I have, with examples. I have 2 databases... DATABASE 1: thepdcom_popgallery TABLE: g2_user [b]g_id    g_userName[/b] 105          Linda DATABASE 2: thepdcom_popnew TABLE: users [b]name[/b] Linda What would you suggest for a script that will output the [b]g_id[/b] (105 above) where [b]name[/b] in users = [b]g_userName[/b] in g2_user? I'm guessing you'd use a JOIN type thing... Thanks again.
  4. Let's say you have a simple HTML form with action through a PHP file to store the information in a MySQL database. What is the best/easiest way to secure that form procoess so the form cannot just be stored in any HTML file on a remote server and submitted?
  5. haha thanks :) edit/ tried it, still not working for some reason...hmmm what i have is [code] <?php $url = $_SERVER[REQUEST_URI];   if($url != '/index.php?q=privacy') {   header("Location: error.php");   } else { //Form submitting data goes here   } } ?> [/code]
  6. Hmm that's weird..still not working well let me tell you that the form is located at http://mydomain.com/?q=privacy
  7. The form is included in an index.php file somehow, can I change $url to like http://mysite.com/ or something like that?
  8. Thanks. I can't seem to get it to work. I heard something about placing a password file on the server somewhere?
  9. Have you checked your spam box for the message?
  10. What's the best way to secure a form that has action through a php file? Example: [code]<form action="/process.php" method="POST"> <select name="color">     <option value="red">red</option>     <option value="green">green</option>     <option value="blue">blue</option> </select> <input type="submit" /> </form>[/code] What could I place in process.php so the above script cannot just be placed in a remote HTML file and submitted? Thanks for all of your help!
  11. THANK YOU SO MUCH!!!!!! That was so annoying I tried everything. Thanks again.
  12. Redirection as in what?
  13. This is so important to me, I've been working on it for days and can't figure it out! Any help is MUCH appreciated. Thank you all for all your help. You probably have seen posts like this here but I absolutely cannot figure it out. Everything looks perfect to me. It is a simple INT(11) type column. The explaination for what is trying to get done is in the script below. When I try to view a profile, I get this error, with a different resource Id# for each user. [code] Unable to run Resource id #182: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #182' at line 1 [/code][code] <?php //Privacy mode integrated with user_profile.tpl.php and private_profile.tpl.php // //A user selects either 'Private Mode' (Value of 1) or 'Public Mode' (Value of 2) from //an HTML form. When submitted, their $user->uid (User ID Number) is inserted into column //'uid' in table 'privacymode.' The selected value (either 1 or 2) is also inserted into //that table in column 'privacyid,' in the same row as their $user->uid of course. // //The script selects the 'privacyid' where the $user->uid of the owner of the profile in which the user //is trying to view and if the 'privacyid' is 2, it will show the profile (since it is public), //if it is 1, it will detect if the user who is trying to view is a friend, if they are a friend it will //display the profile. If the user isn't a friend, it will show rejection page. If the user has //not selected private nor public mode, by default, it will show rejection page. function phptemplate_user_profile($user, $fields = array()) { $link = mysql_connect("localhost","thepdcom_popnew","password"); mysql_select_db("thepdcom_popnew",$link); $sql = mysql_query("SELECT privacyid FROM privacymode WHERE (uid = '$user->uid')"); $result = mysql_query($sql) or die ("Unable to run $sql: " . mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); if ($row['privacyid'] == 2){  //public profile return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields)); } else  if ($row['privacyid'] == 1){  //private profile if (@in_array($user->uid, array_keys(buddylist_get_buddies($account->uid))) && user_access('maintain buddy list')) { //user is friend return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields)); } else {  //user is not friend return _phptemplate_callback('private_profile', array('user' => $user, 'fields' => $fields)); } } else  if ($row['privacyid'] == NULL){ //profile user has not selected a privacy mode return _phptemplate_callback('private_profile', array('user' => $user, 'fields' => $fields)); } else { //some error print 'Privacy mode error'; }   } ?>[/code]
  14. is it possible to have more than 1 if statement in an if..for example [code] <?php $row=certain number from sql query if ($row == 2){ return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields)); } else  if ($row == 1){ if (@in_array($user->uid, array_keys(buddylist_get_buddies($account->uid))) && user_access('maintain buddy list')) { return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields)); } else if ($account->uid != $user->uid && user_access('maintain buddy list')) { return _phptemplate_callback('private_profile', array('user' => $user, 'fields' => $fields)); } } else  if ($row == NULL){ return _phptemplate_callback('private_profile', array('user' => $user, 'fields' => $fields)); } else { print 'Privacy mode error'; }   }?> [/code[[/code]
  15. I'm getting this error with the above code.. Unable to run Resource id #187: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #187' at line 1
  16. Thanks for the quick reply. for some reason it's not getting the data.... [code]<?php function phptemplate_user_profile($user, $fields = array()) { $link = mysql_connect("localhost","thepdcom_popnew","pass"); mysql_select_db("thepdcom_popnew",$link); $sql  = mysql_query("SELECT privacyid FROM `privacymode` WHERE uid = $user->uid "); $result = mysql_query($sql) or die ("Unable to run $sql: " . mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); if ($row['privacyid'] == 2){ return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields)); } else  if ($row['privacyid'] == 1){ if (@in_array($user->uid, array_keys(buddylist_get_buddies($account->uid))) && user_access('maintain buddy list')) { return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields)); } else if ($account->uid != $user->uid && user_access('maintain buddy list')) { return _phptemplate_callback('private_profile', array('user' => $user, 'fields' => $fields)); } } else  if ($row['privacyid'] == NULL){ return _phptemplate_callback('private_profile', array('user' => $user, 'fields' => $fields)); }   } ?> [/code]
  17. i have a form where you can choose either 1 or 2 and when submitted it is put into a database table along with that persons uid..the column is INT(10) i justt need script that pulls the data where the uid is that persons uid and if the value is 1, show this..if the vaule is 2, show this would i use mysql_fetch_object?
  18. I'm trying to return a certain template based on two data tables and I thought I did the following correctly but apparently i didn't..anyone see anything? [code]<?php function phptemplate_user_profile($user, $fields = array()) { $userid = $user->uid; $link = mysql_connect("localhost","thepdcom_popnew","password); mysql_select_db("thepdcom_popnew",$link); $query  = mysql_query("SELECT privacyid FROM privacymode WHERE uid = '$user->uid'"); $result = mysql_fetch_object($query); //if profile is private if ($result =1) { //if user is friend if (@in_array($user->uid, array_keys(buddylist_get_buddies($account->uid))) && user_access('maintain buddy list')) { return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));   } //if user is not friend     else if ($account->uid != $user->uid && user_access('maintain buddy list')) { return _phptemplate_callback('private_profile', array('user' => $user, 'fields' => $fields)); ---------------- ---------------- //if profile is public } else if ($result =2) { return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));   } //if nothing was selected else if ($result = NULL) { return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));   } } } ?>[/code]
  19. I've posted something like this beofre but no one seems to know how to do it... I have a table called 'Privacymode' with the columns 'uid' and 'privacyid.' The column 'uid' is the users User ID number, and the 'privacyid' is the users slected privacy mode setting, either a value of 1 (private mode) or 2 (public mode). Now, I created a friend scripts that when a friend is added to your buddylist, their User ID number is inserted into a column 'buddy' next to a column 'uid' in the table buddylist. When a user selects private mode, their profile is only viewable to their friends. When a user selects public mode, their profile is viewable to everyone. I need a script that will do the following: When a user views someones profile, do a database query that pulls data from the table privacymode and looks to see what privacyid the profiles users uid has next to it. if it is null, show the following html <html>profile data</html>, if it is 2, show the following html <html>profile data</html>, if it is 1, pull data from the table buddylist to see if the profiles user uid lines up with the person who is viewing the profiles uid in the column buddy.. example user 4 = bill user 2 = joe joe is viewing bills profile so the script checks privacymode uid privacyid 4      1 since bills privacyid is 1 (private) it checks to see in buddylist uid  buddy 4    2 since bill is joes buddy, it shows show the following <html>MY PROFILE</html>..please help please!! if joe wasn't bills buddy i want it to show the following <html>YOU CANT SEE THIS PROFILE</html> thanks so much you guys have been great
  20. I need to a script that will do this in the following order 1.  connect to a db 2.  select PID from tableb where UID=$user->uid (current user) 3.  if PID =1 print YES if PID=2 print NO any suggestions?
  21. well, someone on this site told me to do this: [code]$sql = "SELECT p.*         FROM profile p         INNER JOIN privacymode pr ON p.UID = pr.UID         LEFT JOIN buddylist b ON p.UID = b.UID AND b.buddy = '$userid'         WHERE p.UID = '$profileid'             AND ((b.UID IS NOT NULL) OR (pr.privacyid = 2) )"; [/code] which would work I think, however, I don't want it to pull the profile data from a table like it is..i want it to simply return a certain function if it's true and return a different function if false in very very very ignorant terms lol: $query = the above. if true.. return function A else return function B
  22. ok i have a form where  person either selects privacy mode (which is a value of 1) or public mode (where it is a value of 2)..when submitted it is placed into a database called privacy mode with a column UID (which inputs the persons UID and a privacyid which inputs the selction they made. I need a profile template to select that table based on that persons UID to see whether they chose 1 (which is private mode) or 2 (public mode)..if they chose 2..they can show the profile because its public mode but if they chose 1 i want the profile to check a 'buddylist' table to see if the person viewing has their user ID in the column 'buddy' next to the persons profile which their trying to viewings 'UID' (in the same row of course) Example.. buddy PERSON A has a UID of 2..PERSON B has a UID of 4 PERSON A pics privacy so the table 'privacymode' has UID  privacyid 2        1 PERSON B is trying to view PERSON A's profile so since PERSON A picked 1 for their privacyid the page checks buddy list for: UID  buddy 2        4 In a nutshell: i want it to do the query and then have it return a function if their is a relationship or if the privacyid is set to 2 (public mode) else return this function instead I'm guessing I'd use INNER JOIN but how would i do this?
  23. I have a php template of the profile, which is where I wanted to place this code... I can't have it pull the profile data from the database.. so if the person is a friend or it is public,it shows the following html..if it is private and theyre not friends..it shows this html instead..how do i do that?
×
×
  • 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.