PHP - Private Message System Help
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>'; ?> Similar TutorialsHello, 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.. 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"]);
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. This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=358545.0 i am making a private messaging system like hotmails where the message list appears on the left. Then when you click on one of them the box on the right loads the email. The problem is i dont really know how to go about it. Anyone have any pointers? Here are some script that i have been working on and i seems to not work so i want to make a select friend list that when they select the friend that they want to send the message to it sends it to them , that sounded stupid but ya. so here is my script , kinda big . pm_inbox.php i did edit the code from its original state because its to big! so here is the sections where is most needed Code: [Select] <?php // Start_session, check if user is logged in or not, and connect to the database all in one included file include_once("scripts/checkuserlog.php"); ?> <?php if (!isset($_SESSION['idx'])) { echo '<br /><br /><font color="#FF0000">Your session has timed out</font> <p><a href="login.php">Please Click Here</a></p>'; exit(); } //THIS IS WHERE I STARTED $selecteduser = $_POST["selecteduser"]; $id = ""; $username = ""; $id = preg_replace('#[^0-9]#i', '', $id); $sql = mysql_query("SELECT * FROM myMembers WHERE id='$id' LIMIT 1"); while($row = mysql_fetch_array($sql)){ $username = $row["username"]; $friend_array = $row["friend_array"]; $check_pic = "members/$id/image01.jpg"; $default_pic = "members/0/image01.jpg"; if (file_exists($check_pic)) { $user_pic = "<img src=\"$check_pic?$cacheBuster\" width=\"218px\" />"; } else { $user_pic = "<img src=\"$default_pic\" width=\"218px\" />"; } $selecteduser .= "<option value='$friend_array'>Friends</option>"; } // Decode the Session IDX variable and extract the user's ID from it $decryptedID = base64_decode($_SESSION['idx']); $id_array = explode("p3h9xfn8sq03hs2234", $decryptedID); $my_id = $id_array[1]; $my_uname = $_SESSION['username']; // Put user's first name into a local variable // ------- ESTABLISH THE INTERACTION TOKEN --------- $thisRandNum = rand(9999999999999,999999999999999999); $_SESSION['wipit'] = base64_encode($thisRandNum); // Will always overwrite itself each time this script runs // ------- END ESTABLISH THE INTERACTION TOKEN --------- ?> <?php // Mailbox Parsing for deleting inbox messages if (isset($_POST['deleteBtn'])) { foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); if ($key != "deleteBtn") { $sql = mysql_query("UPDATE private_messages SET recipientDelete='1', opened='1' WHERE id='$value' AND to_id='$my_id' LIMIT 1"); // Check to see if sender also removed from sent box, then it is safe to remove completely from system } } header("location: pm_inbox.php"); } ?> // Start Private Messaging stuff $('#pmForm').submit(function(){$('input[type=submit]', this).attr('disabled', 'disabled');}); function sendPM ( ) { var pmSubject = $("#pmSubject"); var pmTextArea = $("#pmTextArea"); var sendername = $("#pm_sender_name"); var senderid = $("#pm_sender_id"); var recName = $("#pm_rec_name"); var recID = $("#pm_rec_id"); var pm_wipit = $("#pmWipit"); var url = "scripts_for_profile/private_msg_parse.php"; if (pmSubject.val() == "") { $("#interactionResults").html('<img src="images/round_error.png" alt="Error" width="31" height="30" /> Please type a subject.').show().fadeOut(6000); } else if (pmTextArea.val() == "") { $("#interactionResults").html('<img src="images/round_error.png" alt="Error" width="31" height="30" /> Please type in your message.').show().fadeOut(6000); } else { $("#pmFormProcessGif").show(); $.post(url,{ subject: pmSubject.val(), message: pmTextArea.val(), senderName: sendername.val(), senderID: senderid.val(), rcpntName: recName.val(), rcpntID: recID.val(), thisWipit: pm_wipit.val() } , function(data) { $('#private_message').slideUp("medium"); $("#interactionResults").html(data).show().fadeOut(10000); document.pmForm.pmTextArea.value=''; document.pmForm.pmSubject.value=''; $("#pmFormProcessGif").hide(); }); } }function toggleViewAllFriends(x) { if ($('#'+x).is(":hidden")) { $('#'+x).fadeIn(200); } else { $('#'+x).fadeOut(200); } } // End Private Messaging stuff</script> <style type="text/css"> .hiddenDiv{display:none} #pmFormProcessGif{display:none} .msgDefault {font-weight:bold;} .msgRead {font-weight:100;color:#666;} </style> </head> <body> <div id="bg" class="stage"></div> <div id="container"> <div id="sun" class="stage"></div> <div id="clouds" class="stage"> <div id="stage" class="stage"> <?php include_once "header_template.php"; ?> <a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers('private_message');">Compose Message</a></div><div class="interactContainers" id="private_message"> <form action="javascript:sendPM();" name="pmForm" id="pmForm" method="post" type="hidden"> <font size="+1">Send A Private Message to <strong><em><?php echo "$selecteduser"; ?></em></strong></font><br /><br /> Subject: <input name="pmSubject" id="pmSubject" type="text" maxlength="64" style="width:98%;" /> Message: <textarea name="pmTextArea" id="pmTextArea" rows="8" style="width:98%;"></textarea> <input name="pm_sender_id" id="pm_sender_id" type="hidden" value="<?php echo $_SESSION['id']; ?>" /> <input name="pm_sender_name" id="pm_sender_name" type="hidden" value="<?php echo $_SESSION['username']; ?>" /> <input name="pm_rec_id" id="pm_rec_id" type="hidden" value="<?php echo $id; ?>" /> <input name="pm_rec_name" id="pm_rec_name" type="hidden" value="<?php echo $username; ?>" /> <input name="pmWipit" id="pmWipit" type="hidden" value="<?php echo $thisRandNum; ?>" /> <span id="PMStatus" style="color:#F00;"></span> <br /><input name="pmSubmit" type="submit" value="Submit" /> or <a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers('private_message');">Close</a> <span id="pmFormProcessGif" style="display:none;"><img src="images/loading.gif" width="28" height="10" alt="Loading" /></span></form> </div> <span id="jsbox" style="display:none"></span> </td> </tr> </table> On most website messaging systems when you hit reply on a message it takes you to the compose screen with the reply message auto filled in. Im using a Session to achieved this. My question is how do they make it so each line of the reply has arrows like this > message >> so it seperates the reply from what the person is about to type This has me clueless Hey Guys Im just after advice really with this question Basically I'm trying to design my first message system. One that once a user has read the message you can tick ok and its then gone forever. Now my boss says you have the message table MESSAGE messageID, Message then within the members table you have a field called messageID. Within this field you will store the ID's of all the messages the user has read. Upon login to the website you will check for ID's in the message table that do not exist in the messsageID of the users table. Is this correct or a really bad way of doing this? If I have to do it this way there will be a massive learning curve on my php knowledge. Does anybody know of a better way of doing this or a cool website to learn from? Thanks Danny This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=314181.0 hello dear PHP-Fans - greetings to you - and a happy new year!! i set up a WAMP-System on my openSuse 11.4 system. In order to learn as much as i can bout PHP i want to do some tests and write some scripts. Well the WAMP is allready up and running. Now i try to give the writing access to the folder mkdir /srv/www/ where the php-scripts should go in... i want to give write permission to all to all files in /srv/www As root I generally: mkdir /srv/www/ chown <webmaster usrername> /srv/www/ /srv/www/ should be readable and traversable by all, but only writeable by it's owner (the user designated as the webmaster.) can i do this like mentioned above,... Love to hear from you greetings db1 Hi 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 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?
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/ 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. 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 Dear all , i am trying the following : i have a class named ACCOUNT with many properties in .some of these properties are array , it is like this : Code: [Select] class ACCOUNT { PRIVATE $DB_LINK; PRIVATE $COMP; PRIVATE $BRANCH; PRIVATE $CURRENCY; PRIVATE $GL; PRIVATE $CIF; PRIVATE $SL; PRIVATE $EXIST; PRIVATE $STATUS; private $ACCOUNT_NAME=ARRAY("LA"=>'',"LE"=>'',"SA"=>'',"SE"=>''); private $ACCOUNT_BALANCE =ARRAY('FC_YTD','CV_YTD','CV_BAL','YTD_BAL','BLOCKED_CV','BLOCKED_FC'); private $CY_NAME=ARRAY("LA"=>'',"LE"=>'',"SA"=>'',"SE"=>''); private $ACCOUNT_NAME_USR=ARRAY("LA"=>'',"LE"=>'',"SA"=>'',"SE"=>''); private $LEDGER_NAME= ARRAY("LA"=>'',"LE"=>''); i have created the following method to call any property [code] FUNCTION GET_SPECIFEC_ATT($ATT,$LANG) { $ATT=$ATT."['L$LANG']"; ECHO $this->$ATT; } but i am getting the below error : Notice: Undefined property: ACCOUNT::$BRANCH_NAME['LA'] in D:\wamp\www\EBANK\account.class on line 186 if i used this : Code: [Select] echo $this->BRANCH_NAME['LA']; it is working fine . and the method is working fine i can iam trying to call property which is NOT an array. Can you please help me in what iam doing wrong ? Thanks in advance Hi there people of the PHP forum, This functions intention is to output the same code 4 digit code twice before generating a new one, I can get it to do one fine, but I cannot for the life of me figure out how to get it to repeat twice before changing on the third call. private function KeyGen(){ $Numerical = range(0,9); $Alpha = range("A","Z"); $Keys = array_merge($Numerical, $Alpha); return $Keys[rand(0,35)].$Keys[rand(0,35)].$Keys[rand(0,35)].$Keys[rand(0,35)]; } I am needing it to do this so that each 'set' of 2 calls to the function (within the class) gives the same 4 digit code. At the moment I am just making one call & then assigning that single call to a variable and then referencing that var twice, this is not what I want to do, but it scratches the itch for now... Any idea's/other logic would be greatly appreciated. Cheers, Rw Hello, I've got a huge database that is filled with text. It is encoded in UTF8 and some of the symbols used (like emoticons) are encoded in the private use area of UTF8 (http://www.fileformat.info/info/unicode/block/private_use_area/utf8test.htm). Now I want to replace those codes of the private use area with the corresponding smilies etcetera. So actually my question is, how do I replace specific UTF8 codes with something else in PHP? Thanks in advance! Hi, when i extend a class containing a private variable and then access the variable in the extended class it doesn't produce any error and works fine and when i access the variable using the object of the extended class it works even then, i think private variable should not be accessable in an extended class neither by object of that extended class here is the code <?php class textbox{ var $body_text, $body_text1; private $body_private="this is private value"; protected $body_protect="this is protected value"; function __construct($text_in, $text_out){ $this->body_text=$text_in; $this->body_text1=$text_out; } function display(){ echo "$this->body_text<br>"; echo "<i>"; echo "$this->body_text1</i><br>"; echo "$this->body_private<br/>"; echo "$this->body_protect<br/>"; } function test_new(){ echo "see if this private echo works"; } } $box=new textbox("any new value","any old value" ); $box->display(); $box->body_text="this is public thats why i can access it"; $box->body_text1="this is public thats why i can access it"; /*$box->body_private="this is private value changed"; //you will see we can't access the private and protected memebers from outside $box->body_protect="this is protected value changed"; */ $box->display(); $box->test_new(); class textboxbold extends textbox{ function __construct($text_on, $text_off, $text_get, $text_go) {$this->body_text=$text_on; $this->body_text1=$text_off; $this->body_protect=$text_get; $this->body_private=$text_go; } function display(){ echo "<b>$this->body_text</b><br>"; echo "<b>$this->body_text1</b><br>"; echo "<b>$this->body_protect</b><br>"; echo "<i>$this->body_private</i><br>"; } } $boxnew=new textboxbold("new Bold text", "text in bold","protected member","private"); $boxnew->display(); $boxnew->body_private="this is simple text taken from outside"; $boxnew->display(); $boxnew->test_new(); ?> please recommend, is it working as it should be 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. |