PHP - Php Private And Public Pages
Hi i created a website where you cam view ip webcams via php. I want to make it so people can make the camera private and public.
I made two fields in mysql called "Username" and "Puborprivate" I tried to make the "Puborprivate" have two numbers "0" would be private and "1" would be public. How could I do this? My site is cwuforum.com/live/ Similar TutorialsHi folks, I had a working, editable profile but it wasn't visible to other users. So I'm trying to make that conversion now. Here's the current 'myprofile' code: <?php session_start(); include('config.php'); include('date.php'); $id = $_GET['id']; $sql = mysql_query("SELECT * FROM members WHERE id = '$id' LIMIT 1"); $check = mysql_num_rows($sql); $check = mysql_query($sql_user_verify) or die('Cannot Execute:'. mysql_error()); if ($check > 1) { echo "No one matches that id number!"; exit(); } if($check == 1) { while($row = mysql_fetch_array($sql)) { $user = $id; echo "<h2>Profile</h2> <table>"; $row = mysql_fetch_array($sql); echo "<tr><th>ID#:</th><td>".$user."</td></tr> <tr><th>Name: </th><td>".$row['callname']."</td></tr> <tr><th>Email: </th><td>".$row['email']."</td></tr> <tr><th>Password: </th><td><input type='password' value='".$row['password']."' disabled='true' /></td></tr> <tr><th>Registered: </th><td>".$row['registered']."</td></tr> <tr><th>Last Login: </th><td>".$row['lastlogin']."</td></tr>"; echo "</table><br />"; } if($id = $_SESSION['id']) { echo "<h2>Profile</h2> <form method='post' action='editprofile.php'> <table>"; $row = mysql_fetch_array($sql); echo "<tr><th>ID#:</th><td>".$user."</td></tr> <tr><th>Name: </th><td>".$row['callname']."</td></tr> <tr><th>Email: </th><td>".$row['email']."</td></tr> <tr><th>Password: </th><td><input type='password' value='".$row['password']."' disabled='true' /></td></tr> <tr><th>Registered: </th><td>".$row['registered']."</td></tr> <tr><th>Last Login: </th><td>".$row['lastlogin']."</td></tr>"; echo "</table><br /> <input type='submit' value='edit profile' /> </form>"; } } else { die (); } ?> <?php include('footer.php'); ?> Here's the link to the user's own profile: <a href=myprofile.php?id='.$id.'>Profile</a> And here's the edit profile link, which works fine: <?php include('config.php'); include('date.php'); if(isset($_POST['btnedit'])){ $callname = $_POST['callname']; $email = $_POST['email']; $password = $_POST['password']; $sql = mysql_query( "UPDATE users SET callname='".$callname."', email='".$email."', password='".$password."' WHERE id='".$_SESSION['id']."'" ); if($sql){ echo "<script>alert('profile updated');window.location='myprofile.php'</script>"; }else{ echo "<script>alert('updating profile failed!');</script>"; } } $sql = mysql_query( "SELECT * FROM users WHERE id='".$_SESSION['id']."'" ); $row = mysql_fetch_array($sql); $userfinal = $_SESSION['id']; $user = $userfinal; echo "<h2>Edit profile</h2> <form method='post'> <table><tr><th>ID#:</th><td>".$user."</td></tr> <tr><th>Name:</th><td><input type='text' name='callname' value='".$row['callname']."'/></td></tr> <tr><th>Email:</th><td><input type='text' name='email' value='".$row['email']."'/></td></tr> <tr><th>Password:</th><td><input type='password' name='password' value='".$row['password']."'/></td></tr> <tr><th>Registered:</th><td>".$row['registered']."</td></tr> <tr><th>Last Login:</th><td>".$row['lastlogin']."</td></tr> </table><br /> <input type='submit' name='btnedit' value='update' /> </form>"; ?> <?php include('footer.php'); ?> It fails, it says the query was empty, even though there are user accounts created and information is being stored (as it worked fine before I tried editing the code to make it public. What am I doing wrong? Hi, I am making a dating site where I have made the user profile edit page visible to the user when they log in, and I think I can get away with not showing the user their "public" profile view. But I definitely need to show other users on the site the "public" non editing profile page view. But I don't know how to do this. I have yet to create the search, search results, thumbnails with optional descriptions of the possible dating results. But I first want to just get 2 versions of the user profile page view. One that the user sees that I have already done. (The editable one). And the other I need to make which is the page the other users will see, (The public profile) Please if anyone has any idea how to do this I would greatly appreciate it, especially if you have any pseudocode ideas. thank you. Hi, I want to create a simple online buying site. I have an admin site with login where admin can add items to the database table, and change other fields such as price and description of product and I want to make a public html page to display the updates made in my admin page. I appreciate it if someone give me some suggestions on how to get started. My admin php scripts is working fine (so SQL queries for UPDATE, DELETE, INSERT) but I don't know how to 'sync' it with the an nice html table of products the user can checkbox off to purchase on the public website. Let me know, thanks. How can I call a public function inside of another public function? The get_primary_edge() says it's undefined, but it's just another public function in the class so shouldn't this work? Code: [Select] public function get_dynamic_edge($uid) { $uid = (int)$uid; $sql = "( SELECT `users`.`id` FROM partners INNER JOIN `users` ON `partners`.`user_id` = `users`.`id` WHERE partners.friend_id = '${uid}' AND `approved` = 1 ) UNION ALL ( SELECT `users`.`id` FROM `partners` INNER JOIN `users` ON `partners`.`friend_id` = `users`.`id` WHERE `partners`.`user_id` = '${uid}' AND `approved` = 1 )"; $result = mysql_query($sql) or die(mysql_error()); $i = 0; while (($row = mysql_fetch_assoc($result)) !== false) { $dynamic[$i] = array( 'uid' => $row['id'], 'score' => get_primary_edge($row['id']), ); $i++; } print_array($dynamic); } I'm learning MVC and getting a bit confused with the accessibility of variables in classes... Code: [Select] class Load { public $load2; } Does this mean that the variable $load2 will be accessible just by all functions within the class Load? or: Does that mean that the variable $load2 will be accessible by all other classes, eg model, controller...etc inc all the functions within? I have the following static method: public static function query($query){ self::$num_queries++; return mysql_query($query)or die(mysql_error()); } I then call it like this: $oql = Mysql::query("SELECT first FROM members WHERE member_id = '{$this->owner}'"); $rql = mysql_fetch_assoc($oql); I then get the following error: Quote Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /incl/php/classes/Photo.php on line 13 Why am I getting this error? ../ tells the php program to go up a level. Code: [Select] require_once '../directory/somefile.php'; Is there a shortcut to go to the public web folder? For example. The following file is placed 3 folders deep: "var/www/deep/deeper/verydeep/index.php" and it requires a file with location: "var/www/thisfile.php" I there a short cut/ quicker method to?? Code: [Select] require_once '../../../thisfile.php'; Hi everyone. Getting my head back into PHP after a long time away, so pardon the newbie question! I would like to create a simple website that is private to me and a few select people. The intention is to be able to share pictures or files. (Sort of my like my own personal dropbox.) Looking to put up some Holiday photos, so this needs to be a quick endeavor. I was thinking of creating a php page that is a log in page. No database, but f the user enters the correct username and password then I could reveal photos or maybe links to other pages. How does that sound? I have done .htaccess files in the past, but they sorta look crude and might scare non-technical people away. Thoughts?
im setting up a php and jQuery pm system and have run into a problem. When a user clicks on a message in the left column the right column is supposed to be populated with the message contents, however the content stays the same whichever message is clicked. Code: (php) [Select] <?php $query = $link->query("SELECT * FROM ".TBL_PREFIX."messages WHERE m_sent_to = '$user_name'") or die(print_link_error()); $row = $query->fetchAll(); foreach($row as $key => $value) { $_message_list .= '<dl class="message_row" id="row-'.$row[$key]['m_mid'].'">'; $_message_list .= '<dd class="message_author">'.profile_link($row[$key]['m_author']).'</dd>'; $_message_list .= '<dd class="message_date">'.asf_date($row[$key]['m_date_sent'], 'short').'</dd>'; $_message_list .= '<dd class="message_checkbox"><input type="checkbox" id="checkbox-'.$row[$key]['m_mid'].'" /></dd>'; $_message_list .= '<dd class="message_subject">'.$row[$key]['m_subject'].'</dd>'; $_message_list .= '</dl>'; $template->message_content = $row[$key]['m_content']; } ?> and the jQuery Code: (js) [Select] <script type="text/javascript"> $j = jQuery.noConflict(); $j(document).ready(function(){ $j('dl.message_row').click(function(){ $j('li.message').html('<?php echo $this->message_content; ?>'); }); }); </script> The content display is always the content of the last message. im trying to make a private message system now when i send a message it works fine but when i open the message at the other end i get a blank message. now i think the problem is with $messageid = $_GET['messages'] when i echo $messageid i get nothing, if i use the print_r($_GET) it returns Array ( [messageid] => 12 ). thanks Code: [Select] <?php session_start(); $myusername=$_SESSION['myusername']; require "database.php"; $messageid = $_GET['messages']; $message = mysql_query("SELECT * FROM messages WHERE message_id = '$messageid' AND to_user = '$myusername'"); $message=mysql_fetch_assoc($message); echo "$message"; echo "<h1>Title: ".$message['message_title']."</h1><br><br>"; echo "<h3>From: ".$message['from_user']."<br><br></h3>"; echo "<h3>Message: <br>".$message['message_contents']."<br></h3>"; echo '<form name="backfrm" method="post" action="inbox.php">'; echo '<input type="submit" value="Back to Inbox">'; echo '</form>'; ?> I am modifying someones existing coldfusion web app. I am adding php processing pages to do various tasks. Up to this point I have just been calling the php pages, and interacting with the web app by passing variables via the url. Current usage: Code: [Select] public.cfm calls processing.php?id=69 Then processing will do what it has too, then ultimately: Code: [Select] header("Location: $publichome?id=$id&importantstuff=$stuff"); exit(); And the webapp will pick up where it has too. But now one of my scripts has to send a JSON object back instead of simple variables. I don't know how to get this done. I tried doing a post with cURL but that wasn't working because I need the public facing coldfusion page to take over and curl returns to the php script (I know I can echo the body of the curl result but this keeps me on the php script domain which I dont want). Is there a way to do the above header location and send an object because thats what I need - the php script to stop and the coldfusion page to be served up with the object to work with. Do I have to create some sort of JSON service in php, that the coldfusion page will call an retrieve the result? If so how? I am writing a script which will be dependent on the client's public ip address. e.g.
if the client is using ip address 203.122.55.124 script A should run and if else then script B should run. Now I know that the If and else will be used but cant guess how will the public ip be captured.
Please help
This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=316783.0 edited: please note all wmv files are not more than 10 or 20 seconds long. also their size is no more than 500kb. I have this following code that works for photos, but wish to alter this slightly so it will work for video files (wmv) getFtpImage.php Code: [Select] <? header('Content-Type: image/jpg'); $imgdir = '/home/mysite/ftpfolder'; readfile($imgdir . '/' . $_GET['file']); ?> index.php Code: [Select] $imgdir = '/home/mysite/ftpfolder'; // the directory, where your images are stored $allowed_types = array('png','jpg','jpeg','gif'); // list of filetypes you want to show $dimg = opendir($imgdir); while($imgfile = readdir($dimg)) { if(in_array(strtolower(substr($imgfile,-3)),$allowed_types)) { $a_img[] = $imgfile; sort($a_img); reset ($a_img); } } $totimg = count($a_img); // total image number for($x=0; $x < $totimg; $x++) { $size = getimagesize($imgdir.'/'.$a_img[$x]); // do whatever $halfwidth = ceil($size[0]/2); $halfheight = ceil($size[1]/2); ?><img src="getFtpImage.php?file=<? echo ($a_img[$x]); ?>" height="180"><? // echo 'name: '.$a_img[$x].' width: '.$size[0].' height: '.$size[1].'<br />'; } i have the images show to fill the screen and wish for the video page to do the same and with the videos you click the [play] in the center of the video image to play it like most videos play, not like the flash. I have searched around and found this code that suggests that I should be able to read an image file and echo it directly in to the page without hyperlinking to the file that is outside the public folder, but i get the error message that it is not there even though the file is. Warning: getimagesize() [function.getimagesize]: Unable to access "/home/****/upload/AAABBBCCC.JPG" in /home/****/public_html/client.php on line 40 Code: [Select] $image = "AAABBBCCC.JPG"; $path= "/home/****/upload/"; $details = getimagesize($path . $image); header ('Content-Type: ' . $details['mime']); echo file_get_contents($path . $image); <? for ($i = 1; $i <= $first_day_of_month-1; $i++) { $days_so_far = $days_so_far + 1; $count_boxes = $count_boxes + 1; echo "<td width=\"125\" height=\"100\" class=\"beforedayboxes\"></td>\n"; } for ($i = 1; $i <= $days_in_month; $i++) { $days_so_far = $days_so_far + 1; $count_boxes = $count_boxes + 1; IF($_GET['month'] == $todays_month+1){ IF($todays_date == $day){ $class = "publicholidayhighlightedboxes"; } ELSE { $class = "dayboxes"; } } ELSE { IF($i == $todays_date){ $class = "highlighteddayboxes"; } ELSE { $class = "dayboxes"; } } The problem is I can only display one highlighted box in one month. For example, in November, there are two public holidays, but only 1 public holiday box is highlighted. Would appreciate if someone can help me out asap. Thank you Hi Guys
I'm building a php application where users must login to access a set of private images. The images display as a set of thumbs to the user, which they can click to download the full size image. so I need to read a whole batch images (500+) of them from a directory.
So I'd like some advice on the best way to:
1) Keep files from being world readable. I know you could probably achieve this using htaccess or storing them outside the document root but which is best given that I need to read a whole directory with hundreds of images? 2) How to access the images If it turns out storing the images off document root is the way to go, what's the most efficient way to read a directory off the doc root and access the individual images (readfile for instance)? Thanks in advance, Drongo Hello World ! i got this script of PM system on my website where 2 or 3 users can send PM to each other it work ok but it <?php header : PM (unread count) $msgs_count = GetUnreadMessagesCount($session_user["id"]); and got this in the Index header : PM <span>( <?=$msgs_count;?> )</span> /* Hello World ! i got a website where 2 or 3 users can create and send PM everything work good but have this bug . */ Example message thread#id1 Sender: A send the message to B & C ok now B & C got PM (1) B make reply to this PM and C the same now the bug is userA will have PM(2) like he have 2unread messages but is different reply in the same message so need to count only (1) by Thread not reply ok if A read it and send new reply now B & C will have PM (3) i hope someone can help me with this code thank you ! this is message_tbl for database <?php $tbl_messages_fields = array( "id" => "INTEGER PRIMARY KEY AUTO_INCREMENT", "threadId" => "INT(11)", "type" => "VARCHAR(4)", "heldById" => "INT", "fromId" => "INT", "toId" => "VARCHAR(32)", "isRead" => "INT(1) $d0", "isStarred" => "INT(1) $d0", "isDeleted" => "INT(1) $d0", "subject" => "VARCHAR(150)", "message" => "VARCHAR(10000)", "timestamp" => "INT(12)"); SetupTable('tbl_messages', $tbl_messages_fields); function UpdateMessageField($conditions, $field, $value){ global $dbPrep; $add = array(); foreach($conditions as $key=>$val){ $add[] = "`$key`=:$key"; } $add = implode(" AND ", $add); $sql = "UPDATE `tbl_messages` SET $field=:$field WHERE $add"; $query = $dbPrep->prepare($sql); $data = array_merge($conditions, array("$field"=>$value)); $query->execute($data); } function GetMessagesQuery($data = array(), $complexConditions = "", $extra = ""){ $dbPrep = GetDatabaseConnection(); $sql = "SELECT * FROM `tbl_messages` "; $add = " "; foreach($data as $key=>$value){ $add.= "AND `$key`=:$key "; } $add = ($add != " ") ? "WHERE" . substr($add, 4, strlen($add)) : $add; $sql.= $add." ".$complexConditions." ".$extra; $query = $dbPrep->prepare($sql); $query->execute($data); return GetRows($query); } function GetThreadQuery($conditions = array(), $complexConditions = "", $extra = ""){ global $dbPrep; $add = array(); foreach($conditions as $key=>$val){ $add[] = "`$key`=:$key"; } $add = implode(" AND ", $add); $sql = "SELECT a.*, b.username AS fromUsername, b.type AS fromType FROM `tbl_messages` AS a "; $sql .= "INNER JOIN `tbl_users` AS b ON a.fromId=b.id "; $sql .= "WHERE $add ORDER BY timestamp ASC"; #echo $sql; $query = $dbPrep->prepare($sql); $query->execute($conditions); return GetRows($query); } $p_NewMessage = $dbPrep->prepare("INSERT INTO `tbl_messages` (type, threadId, heldById, fromId, toId, subject, message, timestamp) VALUES (:type, :threadId, :heldById, :fromId, :toId, :subject, :message, :timestamp);"); $sql = "SELECT a.*, b.type as fromType FROM `tbl_messages` AS a "; $sql .= "INNER JOIN `tbl_users` AS b ON a.fromId=b.id "; $sql .= "WHERE threadId=:id AND heldById=:heldById AND isDeleted=0 ORDER BY timestamp ASC"; $p_GetSingleMessage = $dbPrep->prepare($sql); function UnDeleteThread($threadId, $heldById){ global $dbPrep; $p_UnDeleteThread = $dbPrep->prepare("UPDATE `tbl_messages` SET isDeleted=0,isRead=0 WHERE threadId=:threadId AND heldById=:heldById"); $p_UnDeleteThread->execute(array("threadId"=>$threadId, "heldById"=>$heldById)); } function GetRecipients($sessId, $fromId, $toId){ $allParties = $sessId . "," . $fromId . "," . $toId; $arr = array_unique(explode(",", $allParties)); if (($key = array_search($sessId, $arr)) !== false) { unset($arr[$key]); } return implode (",", $arr); } function GetRecipientName($id){ global $dbPrep; $sql = "SELECT username FROM `tbl_users` WHERE id=:id"; $query = $dbPrep->prepare($sql); $query->execute(array("id"=>$id)); $row = $query->fetch( PDO::FETCH_ASSOC ); return $row["username"]; } function GetRecipientNames($recipients){ $all = explode(",", $recipients); $val = array(); foreach ($all as $a){ $val[] = GetRecipientName($a); } return $val; } $p_GetUnreadMessagesCount = $dbPrep->prepare("SELECT COUNT(*) FROM `tbl_messages` WHERE isRead=0 AND heldById=:heldById AND type='recv'"); $unreadMsgsCount = -1; function GetUnreadMessagesCount($uid){ global $unreadMsgsCount; global $p_GetUnreadMessagesCount; if($unreadMsgsCount == -1){ $p_GetUnreadMessagesCount->execute(array("heldById"=>$uid)); $unreadMsgsCount = $p_GetUnreadMessagesCount->fetch( PDO::FETCH_ASSOC ); $unreadMsgsCount = $unreadMsgsCount["COUNT(*)"]; } return $unreadMsgsCount; } function GetNewThreadId(){ global $dbPrep; $threadId = 1; $p_GetLatestThreadId = $dbPrep->prepare("SELECT MAX(threadId) FROM `tbl_messages`"); $p_GetLatestThreadId->execute(); $latestThreadId = $p_GetLatestThreadId->fetch( PDO::FETCH_ASSOC ); if($latestThreadId){ $threadId = $latestThreadId["MAX(threadId)"]+1; } return $threadId; } ?> if(isset($_REQUEST["mark_read"])){ if(isset($_REQUEST["message_all_toggle"])) foreach($_REQUEST["message_all"] as $m) SetNotificationRead($m, $session_user["id"], 1); elseif(isset($_REQUEST["message"])) foreach($_REQUEST["message"] as $m) SetNotificationRead($m, $session_user["id"], 1); else foreach($_REQUEST["message_all"] as $m) SetNotificationRead($m, $session_user["id"], 1); } if(isset($_REQUEST["mark_unread"])){ if(isset($_REQUEST["message_all_toggle"])) foreach($_REQUEST["message_all"] as $m) SetNotificationRead($m, $session_user["id"], 0); elseif(isset($_REQUEST["message"])) foreach($_REQUEST["message"] as $m) SetNotificationRead($m, $session_user["id"], 0); else foreach($_REQUEST["message_all"] as $m) SetNotificationRead($m, $session_user["id"], 0); } if(isset($_REQUEST["delete"])){ if(isset($_REQUEST["message_all_toggle"])) foreach($_REQUEST["message_all"] as $m) RemoveNotificationById($m, $session_user["id"]); elseif(isset($_REQUEST["message"])) foreach($_REQUEST["message"] as $m) RemoveNotificationById($m, $session_user["id"]); } } else { if(isset($_REQUEST["delete"])){ if(is_numeric($_REQUEST["delete"])){ UpdateMessageField(array("threadId"=>$_REQUEST["delete"], "heldById"=>$session_user["id"]), "isStarred", 0); UpdateMessageField(array("threadId"=>$_REQUEST["delete"], "heldById"=>$session_user["id"]), "isDeleted", 1); UpdateMessageField(array("threadId"=>$_REQUEST["delete"], "heldById"=>$session_user["id"]), "isRead", 1); }elseif(isset($_REQUEST["message_all_toggle"])){ $messages = $_REQUEST["message_all"]; foreach($messages as $m){ UpdateMessageField(array("threadId"=>$m, "heldById"=>$session_user["id"]), "isStarred", 0); UpdateMessageField(array("threadId"=>$m, "heldById"=>$session_user["id"]), "isDeleted", 1); UpdateMessageField(array("threadId"=>$m, "heldById"=>$session_user["id"]), "isRead", 1); } }elseif(isset($_REQUEST["message"])){ $messages = $_REQUEST["message"]; foreach($messages as $m){ UpdateMessageField(array("threadId"=>$m, "heldById"=>$session_user["id"]), "isStarred", 0); UpdateMessageField(array("threadId"=>$m, "heldById"=>$session_user["id"]), "isDeleted", 1); UpdateMessageField(array("threadId"=>$m, "heldById"=>$session_user["id"]), "isRead", 1); } } } if(isset($_REQUEST["messagestar"])){ if(isset($_REQUEST["message_all_toggle"])){ $messages = $_REQUEST["message_all"]; foreach($messages as $m){ UpdateMessageField(array("threadId"=>$m, "heldById"=>$session_user["id"]), "isStarred", 1); } }elseif(isset($_REQUEST["message"])){ $messages = $_REQUEST["message"]; foreach($messages as $m){ UpdateMessageField(array("threadId"=>$m, "heldById"=>$session_user["id"]), "isStarred", 1); } } } if(isset($_REQUEST["deletestarred"])){ if(isset($_REQUEST["message_all_toggle"])){ $messages = $_REQUEST["message_all"]; foreach($messages as $m){ UpdateMessageField(array("threadId"=>$m, "heldById"=>$session_user["id"]), "isStarred", 0); } }elseif(isset($_REQUEST["message"])){ $messages = $_REQUEST["message"]; foreach($messages as $m){ UpdateMessageField(array("threadId"=>$m, "heldById"=>$session_user["id"]), "isStarred", 0); } } } if(isset($_REQUEST["mark_unread"])){ if(isset($_REQUEST["message_all_toggle"])){ $messages = $_REQUEST["message_all"]; foreach($messages as $m){ UpdateMessageField(array("threadId"=>$m, "heldById"=>$session_user["id"]), "isRead", 0); } }elseif(isset($_REQUEST["message"])){ $messages = $_REQUEST["message"]; foreach($messages as $m){ UpdateMessageField(array("threadId"=>$m, "heldById"=>$session_user["id"]), "isRead", 0); } } } if(isset($_REQUEST["mark_read"])){ if(isset($_REQUEST["message_all_toggle"])){ $messages = $_REQUEST["message_all"]; foreach($messages as $m){ UpdateMessageField(array("threadId"=>$m, "heldById"=>$session_user["id"]), "isRead", 1); } }elseif(isset($_REQUEST["message"])){ $messages = $_REQUEST["message"]; foreach($messages as $m){ UpdateMessageField(array("threadId"=>$m, "heldById"=>$session_user["id"]), "isRead", 1); } } } } $details = isset($_REQUEST["details"])?$_REQUEST["details"]:0; $session_user = GetUserById($session_user["id"]);
Hello, i have a private message system nearly done , the only thing that i cant get to work is the Trash messages that a user has... so the user can delete messages either from the inbox/sent/friends box ... then each message row gets update with pm_sender_is_deleted='1' or pm_reciever_is_deleted='1' , depends if the message was deleted in the inbox or sent box respectively. Here is my db structure on the first table: pm_id int(11) pm_msg_id int(11) pm_sender_id varchar(30) pm_reciever_id varchar(30 pm_sender_isSpam tinyint(1) pm_sender_isRead tinyint(1) pm_sender_is_deleted tinyint(1) pm_sender_is_removed tinyint(1) pm_reciever_isSpam tinyint(1) pm_reciever_isRead tinyint(1) pm_reciever_is_deleted tinyint(1) pm_reciever_is_removed tinyint(1) here is the second: usermessages_id int(11) usermessages_msg_id int(11) usermessages_sender_id varchar(30) usermessages_reciever_id varchar(30) usermessages_subject varchar(300) usermessages_content usermessages_created_at datetime usermessages_canReply tinyint(1) When a user decides to delete a message i update the _is_deleted as i said above successfully. It seems that i cant get the a correct SQL code to display the mesages that i have deleted... These 3 queries tells how many msgs are in the trash for each user: //get messages that i have sent to myself $get_same = mysql_query("SELECT * FROM glr_pm_data WHERE pm_sender_id='$email' && pm_reciever_id='$email' && pm_sender_is_deleted='1' && pm_reciever_is_deleted='1' && pm_sender_is_removed='0' && pm_reciever_is_removed='0'"); $same = mysql_num_rows($get_same); //get messages that i have recieved $get_rec = mysql_query("SELECT * FROM glr_pm_data WHERE pm_reciever_id='$email' && pm_reciever_is_deleted='1' && pm_sender_id!='$email' && pm_reciever_is_removed='0'"); $new = mysql_num_rows($get_rec); //get messages that i have sent to others and NOT to myself $get_snd = mysql_query("SELECT * FROM glr_pm_data WHERE pm_sender_id='$email' && pm_sender_is_deleted='1' && pm_sender_is_removed='0' && pm_reciever_id!='$email'"); a query i have tried to display the trash messages is: $query = "SELECT * FROM glr_pm_data INNER JOIN glr_usermessages ON glr_pm_data.pm_msg_id=glr_usermessages.usermessages_msg_id && (pm_sender_id='$email' && pm_reciever_id='$email' && pm_sender_is_deleted='1' && pm_sender_is_removed='0' && pm_reciever_is_deleted='1' && pm_reciever_is_removed='0') || (pm_reciever_id='$email' && pm_sender_id!='$email' && pm_reciever_is_deleted='1' && pm_reciever_is_removed='0') || (pm_sender_id='$email' && pm_reciever_id!='$email' && pm_sender_is_deleted='1' && pm_sender_is_removed='0') ORDER BY glr_pm_data.pm_id DESC $limit"; So if anyone can help me out create a correct query to display the trash messages i would appreciate.. Hey all, I'm sure this is a really basic question but I'd like a definite answer. I've been watching a tutorial and seeing some site references regarding connecting to a sql database using php. Since it contains a password to the database, my question is, how secure is this page on a webserver, or does it not even matter since the code is so specific to the website and the database it is connecting to.
Thank you in advance. |