PHP - Php (oop - Pdo) Get Last Unread Reply
Hello. My first topic here was about getting the amount of unread messages. I'm now working on showing the unread messages in the inbox. Let's say we have 2 users. User1 sends user2 a message with the title: this is a title. User2 read the message and replied. User1 now has to see: this is a title. This is the code in: class Pm {} public function get_unread_pm() { $stmt = $this->db->prepare(' SELECT pm.title, pm.sender_id, pm.timestamp, (SELECT COUNT(pm2.id) FROM pm as pm1, pm as pm2 WHERE pm1.parent_id=pm2.id) AS replies, u.username as sender FROM pm LEFT JOIN users AS u ON u.id=pm.sender_id WHERE pm.receiver_id=:user_id AND pm.unread=1 AND pm.parent_id=pm.id'); $stmt->bindParam('user_id', $_SESSION['userid']); $stmt->execute(); return $stmt->fetchAll(); } I now get the original message because of the pm.parent=pm.id, but I want to get the message where the parent_id of a reply is the same parent_id as where the parent_id is equal to it's id. I think a less complicated description is: How do I get the last reply instead of the original message?
parent_id: When I reply to a message, my id still counts up, the parent_id is the id of the original message. This is what my data-table looks like:
The content:
If I'm doing this stuff really inefficient, I would be happy to know how to make it better Fabian Edited September 19, 2019 by FabelSimilar TutorialsI cant get this to work and I found a host with imap-ssl here is my code though i've been messing around with it. It cant get the imap_open to work. Code: [Select] $mbox = imap_open ("{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox", "username", "password", OP_READONLY) or die("can't connect: " . imap_last_error()); $check = imap_mailboxmsginfo($mbox); echo $check->Unread; / Please please help. Thanks I am trying to run this but it wont work. I get the following error. Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox in /home/u984345410/public_html/default.php Here is a snipit of the code Code: [Select] function CountUnreadMails($login, $passwd) { $mbox = imap_open("{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox", $login, $passwd, OP_READONLY); $count = 0; if (!$mbox) { echo "Error"; } else { $headers = imap_headers($mbox); foreach ($headers as $mail) { $flags = substr($mail, 0, 4); $isunr = (strpos($flags, "U") !== false); if ($isunr) $count++; } } imap_close($mbox); return $count; } Hey, im trying to create a little function that displays how many unread messages a user has this is my function Code: [Select] function unread() { $sql_pm_r = mysql_query("SELECT COUNT(*) FROM messages WHERE reciever=" . $user . " AND recieved='0'"); $num_rows = mysql_num_rows($sql_pm_r); $sql_pm_check = mysql_query("SELECT id FROM messages WHERE reciever=" . $user . " AND recieved='0' LIMIT 1"); $num_new_pm = mysql_num_rows($sql_pm_check); if ($num_new_pm > 0) { $pms = '<a href="inbox.php" >('.$num_rows.')</a>'; } else { $pms = '<a href="inbox.php" >(0)</a>'; } echo $pms; }and i'm calling it on the index page as normal like Code: [Select] unread(); However not matter how many unread messages i have, i always get (0), this is how my sql table looks id reciever sender subject message recieved Hi, I am learning pdo php and mysql
I would like to know how to see whether a record has been read or not. I have a database messages with id, user_id, contact_id, login, msg, rrecord and msgtime.
The rrecord column has been set as 0 as default. When the client clicks the msg link, I would like it to update the rrecord to 1.
Thanks.
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 working on my own (basic) forum sofware how would I determine if the user has read or unread the topic? (like SMF has a specific icon when viewing the forum/topic list which represents theirs unread topics within this forum). Can someone assist with this, the form works, but the end user cannot simply click on reply, they have to copy/paste. I think it is just a header issue, but i'm not sure and the person who wrote this script is no longer availalble...any help would be much appreciated! Code: [Select] <?php if ($_POST['post'] != '') { $to = 'fetch@domain.com'; $subject = 'Appointment Request'; $message = "A user on the website has submitted an appointment request. Find their details below.\n\n"; $reqd = array('name', 'email', 'phone', 'phonetype1', 'petname'); $disregard = array('post', 'Appointment_Mail_'); $breaks = array('break', 'break2', 'break3'); foreach($_POST as $key=>$value) { if (in_array($key, $reqd) && $value == '') { $error .= '- Fill out '.$key.'<br />'; } elseif (!in_array($key, $disregard)) { if (in_array($key, $breaks)) { $message .= "\n"; } else { $message .= ucwords($key).": ".stripslashes($_POST[$key])."\n"; } } } if ($error == '') { mail('fetch@domain.com', $subject, $message, 'From: domain.com <noreply@domain.com>'); header('Location: http://www.domain.com/thanks.html'); die(); } else { $error = 'Please correct the following errors:<br />'.$error; } } ?> i am making a message system which users can message each other. sending message works fine but having trouble with the reply message cant seem to get to_user value code so far Code: [Select] <?php session_start(); $myusername=$_SESSION['myusername']; require "database.php"; $messageid = $_GET['messageid']; $message = mysql_query("SELECT * FROM messages WHERE message_id = '$messageid' AND to_user = '$myusername'"); $message=mysql_fetch_assoc($message); // problem is here atm getuname returns Resource id instead of the username iam trying to reply to // $getuname= mysql_query("SELECT from_user FROM messages Where message_id='$message_id' AND to_user ='$myusername'"); 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">'; // this where i need to the to user to carry over to the next page// echo '<a href="reply.php?username=' . "$getuname" . '">reply</a>'."<br/>"; echo '</form>'; ?> </body> </html> I want to be able to reply to the sender of the information ( the guy who fills the form online ). your help is much appreciated. here's the code <?php if(isset($_POST['submit'])) { $from = 'From: contactform@nisbetplantation.com'; $to = "reservations@nisbetplantation.com"; $subject = "Website Contact Form"; $name_field = $_POST['name']; $email_field = $_POST['email']; $address_field = $_POST['address']; $address2_field = $_POST['address2']; $city_field = $_POST['city']; $state_field = $_POST['state']; $zip_field =$_POST['zip']; $company_field =$_POST['company']; $IATA_field =$_POST['IATA']; $phone_field =$_POST['phone']; $fax_field =$_POST['fax']; $mail_from="$email"; $response1_field =$_POST['response1']; $areacode_field =$_POST['areacode']; $comments_field =$_POST['comments']; $body = "From: $name_field\n E-Mail: $email_field\n Address:\n $address_field Address2:\n $address2_field City:\n $city_field State:\n $state_field Zip:\n $zip_field Company:\n $company_field IATA:\n $IATA_field Phone:\n $phone_field Fax:\n $fax_field Visited Resort:\n $response1_field Area code:\n $areacode_field Comments:\n $comments_field'"; echo "Your Information has been submitted to $to!"; mail($to, $subject, $body); } else { echo "Please try again after some time..."; } ?> Hi can anyone help this is my forum reply code: <?php include "connect.php"; // Get value of id that sent from hidden field $id=$_POST['id']; // Find highest answer number. $sql="SELECT MAX(a_id) AS Maxa_id FROM reply WHERE question_id='$id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); // add + 1 to highest answer number and keep it in variable name "$Max_id". if there no answer yet set it = 1 if ($rows) { $Max_id = $rows['Maxa_id']+1; } else { $Max_id = 1; } // get values that sent from form $a_name=$_POST['a_username']; $a_answer=$_POST['a_reply']; // Insert answer $sql2="INSERT INTO reply(question_id, a_id, a_username, a_reply, a_date, a_time)VALUES('$id', '$Max_id', '$a_username', '$a_reply', CURDATE(), CURTIME())"; $result2=mysql_query($sql2); if($result2){ echo "Successful<BR>"; echo "<a href='viewtopic.php?id=".$id."'>View your answer</a>"; // If added new answer, add value +1 in reply column $sql3="UPDATE topic SET reply='$Max_id' WHERE id='$id'"; $result3=mysql_query($sql3); } else { echo "ERROR"; } mysql_close(); ?> and this is the error message anyone know why it gives this Thanks Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/fightwa1/public_html/addreply.php on line 10 please help Hi! I have been on the paypal website a lot but I can't find what I am looking for. I trying to find some API so I can show Paypal links on every page I generate from mysql. When the user press Paypal button, he/or she will be redirected to paypal.com with a form where a field with the ID, already is filled in. So let's say I press Paypal button ,then a ID, to that page will be sent to paypal and when the user pay the money, a reply from paypal with the ID will come back and confirm the payment. How can I get this to work? I really hope you can help me with this! Thanks! Hi, I have made personal messaging system however I can't reply unless it is to the last message! I think I've messed up the looping somewhere but can you see if you can figure out what's wrong with it? This is the code for the inbox page: <?php require('scripts/top.php'); ?> <title>Spares List | Your Messages</title> <div id='full'> <?php if ($username){ echo "<a href='create_message.php'>Create Message</a> <div id='box'> <b class='corners'> <b class='corners1'><b></b></b> <b class='corners2'><b></b></b> <b class='corners3'></b> <b class='corners4'></b> <b class='corners5'></b></b> <div class='cornersfg'> <div id='top'>Inbox for $username</div> <div id='bottom' style='padding: 10px;'>"; //////////////////////////////////////////////////////////////////////// require('scripts/connect.php'); $query = mysql_query("SELECT * FROM messages WHERE to_user='$username' ORDER BY id DESC"); $numrows = mysql_num_rows($query); if ($numrows > 0){ echo "<form action='delete_message.php' method='POST'>"; echo "<div id='messages'> <div id='leftside'><input type='checkbox' name='selectall'><input type='submit' name='deleteinbox' value='Delete' class='button'></div> <div id='rightside'>Date</div> <div id='center'>Subject and Message</div> <div style='clear: both;'></div> </div>"; while($row = mysql_fetch_assoc($query)){ $msg_id = $row['id']; $msg_to_user = $row['to_user']; $msg_to_id = $row['to_id']; $msg_from_user = $row['from_user']; $msg_from_id = $row['from_id']; $msg_subject = $row['subject']; $msg_content = $row['content']; $msg_date = $row['date']; $msg_from_delete = $row['from_delete']; $msg_to_delete = $row['to_delete']; if (!$msg_to_delete){ echo "<div id='messages'>"; echo "<div id='leftside'> <input type='checkbox' name='cb$msg_id' value='$msg_id'> <a href='profile.php?id=$msg_from_id' target='_blank'>$msg_from_user</a> </div>"; echo "<div id='rightside'>$msg_date</div>"; echo "<div id='center'> <span class='toggle'><a href='#'>$msg_subject</a></span> <div class='hiddenDiv'> <br>$msg_content<br><br> <span class='toggle'><a href='#'>REPLY</a></span> <div class='hiddenDiv'> <form action='reply.php' method='POST'> <input type='hidden' value='$msg_id' name='replyid'> <input type='text' name='replysubject' style='width: 300px;' class='text-box' value=' $msg_subject'><br> <textarea name='replycontent' style='width: 298px;' rows='5'></textarea><br><br> <input type='submit' name='replybutton' class='button' value='Reply'> </form> </div> </div> </div>"; echo "<div style='clear: both;'></div>"; echo "</div>"; $num += 1; } } if ($num == 0){ echo "You have no messages in your inbox."; } echo "</form>"; } else echo "You have no messages in your inbox."; //////////////////////////////////////////////////////////////////////// echo "</div> </div> <b class='corners'> <b class='corners5'></b> <b class='corners4'></b> <b class='corners3'></b> <b class='corners2'><b></b></b> <b class='corners1'><b></b></b></b> </div>"; ///////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// echo "<div id='box'> <b class='corners'> <b class='corners1'><b></b></b> <b class='corners2'><b></b></b> <b class='corners3'></b> <b class='corners4'></b> <b class='corners5'></b></b> <div class='cornersfg'> <div id='top'>Outbox for $username</div> <div id='bottom' style='padding: 10px;'>"; //////////////////////////////////////////////////////////////////////// require('scripts/connect.php'); $query = mysql_query("SELECT * FROM messages WHERE from_user='$username' ORDER BY id DESC"); $numrows = mysql_num_rows($query); if ($numrows > 0){ echo "<form action='delete_message.php' method='POST'>"; echo "<div id='messages'> <div id='leftside'><input type='checkbox' name='selectall'><input type='submit' name='deleteoutbox' value='Delete' class='button'></div> <div id='rightside'>Date</div> <div id='center'>Subject and Message</div> <div style='clear: both;'></div> </div>"; while($row = mysql_fetch_assoc($query)){ $msg_id = $row['id']; $msg_to_user = $row['to_user']; $msg_to_id = $row['to_id']; $msg_from_user = $row['from_user']; $msg_from_id = $row['from_id']; $msg_subject = $row['subject']; $msg_content = $row['content']; $msg_date = $row['date']; $msg_from_delete = $row['from_delete']; $msg_to_delete = $row['to_delete']; if (!$msg_from_delete){ echo "<div id='messages'>"; echo "<div id='leftside'> <input type='checkbox' name='cb$msg_id' value='$msg_id'> <a href='profile.php?id=$msg_from_id' target='_blank'>$msg_from_user</a> </div>"; echo "<div id='rightside'>$msg_date</div>"; echo "<div id='center'> <span class='toggle'><a href='#'>$msg_subject</a></span> <div class='hiddenDiv'> <br>$msg_content<br><br> </div> </div>"; echo "<div style='clear: both;'></div>"; echo "</div>"; $num += 1; } } if ($num == 0){ echo "You have no messages in your outbox."; } echo "</form>"; } else echo "You have no messages in your outbox."; //////////////////////////////////////////////////////////////////////// echo "</div> </div> <b class='corners'> <b class='corners5'></b> <b class='corners4'></b> <b class='corners3'></b> <b class='corners2'><b></b></b> <b class='corners1'><b></b></b></b> </div>"; echo "</div>"; } else echo "<center><h2><font color='red'>You must be logged in to view this page.</font></h2></center>"; require('scripts/bottom.php'); ?> And this is the code for the deleteorsend php file: <?php include("header.inc"); ?> <table border="0" width="100%"><tr><td valign="top" width="800"> <div id="content"> <?php //Start Content $replybtn = $_POST['replybutton']; $inboxbtn = $_POST['deleteinbox']; $outboxbtn = $_POST['deleteoutbox']; if($_SESSION['uid']){ if ($replybtn){ $subject = $_POST['replysubject']; $content = $_POST['replycontent']; $replyid = $_POST['replyid']; if ($subject && $content){ $date = date("M d, Y"); $query = mysql_query("SELECT * FROM messages WHERE content='$content' AND date='$date'"); $numrows = mysql_num_rows($query); if ($numrows == 0){ $query = mysql_query("SELECT * FROM messages WHERE id='$replyid' AND to_user='$username'"); $numrows = mysql_num_rows($query); if ($numrows == 1){ $row = mysql_fetch_assoc($query); $to_id = $row['from_id']; $to_user = $row['from_user']; mysql_query("INSERT INTO messages VALUES ('', '$to_user', '$to_id', '$username', '$userid', '$subject', '$content', '$date', '0', '0')"); echo "Your reply has been sent. <a href='messages.php'>Click here</a> to return to your inbox."; } else echo "No message was sent. An error has occured!!!!"; } else echo "You can NOT resend the same messages."; } else echo "You did not supply a subject and/or message."; } else if($inboxbtn){ $query = mysql_query("SELECT * FROM messages WHERE to_user='$username'"); while ($row = mysql_fetch_assoc($query)){ $msg_id = $row['id']; $value = "cb"."$msg_id"; $checkbox = $_POST[$value]; if ($checkbox){ mysql_query("UPDATE messages SET to_delete='1' WHERE id='$msg_id'"); } } echo "The selected messages have been deleted! <a href='messages.php'>Click here</a> to return to your inbox."; } else if($outboxbtn){ $query = mysql_query("SELECT * FROM messages WHERE from_user='$username'"); while ($row = mysql_fetch_assoc($query)){ $msg_id = $row['id']; $value = "cb"."$msg_id"; $checkbox = $_POST[$value]; if ($checkbox){ mysql_query("UPDATE messages SET from_delete='1' WHERE id='$msg_id'"); } } echo "The selected messages have been deleted! <a href='messages.php'>Click here</a> to return to your inbox."; } else echo "You must click the button!"; } else echo "You must be logged in to do that!"; //End Content ?> </div> </td><td width="250"> <?php include("sidebar.inc"); ?> </td> </table> <?php include("footer.inc"); ?> </div> </div> I hope you can work out what is wrong as I am quite new to php. Thanks in advanced Cameron I want to be able to reply to the email of the sender ( of the form ) heres the codes <?php $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/")); // Checkbox handling $field_1_opts = $_POST['field_1'][0].",". $_POST['field_1'][1]; mail("harshad@madiganpratt.com","Invitation - Form submission","Form data: rooms: $field_1_opts First Name: " . $_POST['fname'] . " Last Name: " . $_POST['lname'] . " Your Email: " . $_POST['email'] . " Phone Number: " . $_POST['pnumber'] . " Request your arrival date: " . $_POST['field_2'] . " Request your departure date: " . $_POST['field_3'] . " Please send me an ownership package: " . $_POST['field_4'] . " ",$headers); include ("confirm.html"); ?> I've already made fully working create topic, etc; what would I need to make to reply to a thread? I've gotten this so far... <?php $result = mysql_query("SELECT id FROM b ORDER BY id DESC"); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { printf("<a href='reply.php?id=%s'>Reply</a><hr><br /><br />", $row[0]); } mysql_free_result($result); ?> reply.php?id=%s (%s equaling the thread id) when I click it, it does bring me to the appropriate page, but I don't know where to go from there. Any help? any other info you might need just ask Hey guys i have been making a comment and reply script. When the user makes a post and others reply they appear below. However when another person makes a post and a reply is made to that they mess up it has the comments at the top and the replys at the bottom. DOes anyone know how i could order these? Or is there a tutorial online. Hope someone can help. Thanks I just had a question for you guys. I am building a forum script and I'm currently stumped on the "show unread posts since last visit" feature. Not sure as to how to code it. Should I be using a mysql database to keep track of them or use cookies some how? Thanks in advanced! I am working on an http interface to existing apps. These apps make a call to GET a CHUNKED reply with the payload being a Jpg (or series of jpg??) , or a single pdf file
The wireshark trace looks like this: Frame 1093: 209 bytes on wire (1672 bits), 209 bytes captured (1672 bits) on interface \Device\NPF_{9AF84BC1-E1F6-4A31-BC25-33964BBB83EC}, id 0 Ethernet II, Src: Motorola_18:69:75 (84:b8:b8:18:69:75), Dst: IntelCor_f8:a5:5c (a4:34:d9:f8:a5:5c) Internet Protocol Version 4, Src: 192.168.0.150, Dst: 192.168.0.99 Transmission Control Protocol, Src Port: 35138, Dst Port: 8000, Seq: 14994, Ack: 122074, Len: 155 Hypertext Transfer Protocol GET /eSCL/ScanJobs/NextDocument HTTP/1.1\r\n TE: chunked\r\n Host: 192.168.0.99:8000\r\n Connection: Keep-Alive\r\n Accept-Encoding: gzip\r\n User-Agent: okhttp/4.9.1\r\n \r\n [Full request URI: http://192.168.0.99:8000/eSCL/ScanJobs/NextDocument] [HTTP request 98/101] [Prev request in frame: 1091] [Response in frame: 1094] [Next request in frame: 1095] Then I see this in Wireshark, but nothing is ever downloaded the request is made over and over till cancelled: Frame 1094: 1319 bytes on wire (10552 bits), 1319 bytes captured (10552 bits) on interface \Device\NPF_{9AF84BC1-E1F6-4A31-BC25-33964BBB83EC}, id 0 Ethernet II, Src: IntelCor_f8:a5:5c (a4:34:d9:f8:a5:5c), Dst: Motorola_18:69:75 (84:b8:b8:18:69:75) Internet Protocol Version 4, Src: 192.168.0.99, Dst: 192.168.0.150 Transmission Control Protocol, Src Port: 8000, Dst Port: 35138, Seq: 122074, Ack: 15149, Len: 1265 Hypertext Transfer Protocol HTTP/1.1 200 OK\r\n Date: Tue, 13 Jul 2021 11:12:43 GMT\r\n Server: Apache/2.4.48 (Win64) OpenSSL/1.1.1k PHP/8.0.8\r\n Content-Length: 1038\r\n Keep-Alive: timeout=5, max=3\r\n Connection: Keep-Alive\r\n Content-Type: text/html;charset=UTF-8\r\n \r\n [HTTP response 98/101] [Time since request: 0.005202000 seconds] [Prev request in frame: 1091] [Prev response in frame: 1092] [Request in frame: 1093] [Next request in frame: 1095] [Next response in frame: 1096] [Request URI: http://192.168.0.99:8000/eSCL/ScanJobs/NextDocument] File Data: 1038 bytes Line-based text data: text/html (16 lines) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n <html>\n <head>\n <title>Index of /eSCL/ScanJobs/NextDocument</title>\n </head>\n <body>\n <h1>Index of /eSCL/ScanJobs/NextDocument</h1>\n <table>\n <tr><th valign="top"><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr>\n <tr><th colspan="5"><hr></th></tr>\n <tr><td valign="top"><img src="/icons/back.gif" alt="[PARENTDIR]"></td><td><a href="/eSCL/ScanJobs/">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr>\n <tr><td valign="top"><img src="/icons/text.gif" alt="[TXT]"></td><td><a href="index.php">index.php</a> </td><td align="right">2021-07-13 00:43 </td><td align="right">1.0K</td><td> </td></tr>\n <tr><th colspan="5"><hr></th></tr>\n </table>\n <address>Apache/2.4.48 (Win64) OpenSSL/1.1.1k PHP/8.0.8 Server at 192.168.0.99 Port 8000</address>\n </body></html>\n
So how do I get Apache/PHP to respond to this GET CHUNKED request in a way the client understands? Edited July 13 by markosjal what line of code should i add in order to be able to reply to the sender of contact form. right now its showing the last email created in the server. heres the code <?php $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/")); // Checkbox handling $field_1_opts = $_POST['field_1'][0].",". $_POST['field_1'][1]; mail("randy@reefsclub.com","Invitation - Form submission","Form data: rooms: $field_1_opts First Name: " . $_POST['fname'] . " Last Name: " . $_POST['lname'] . " Your Email: " . $_POST['email'] . " Phone Number: " . $_POST['pnumber'] . " Request your arrival date: " . $_POST['field_2'] . " Request your departure date: " . $_POST['field_3'] . " Please send me an ownership package: " . $_POST['field_4'] . " ",$headers); include ("confirm.html"); ?> Code: [Select] $IP = $_SERVER['REMOTE_ADDR']; $DATE = date("Y-m-d"); $TIME = date("H:i:s"); $NameOfSender = "BLABLABLABALLA"; $email = $fieldnm_3; // use their addy instead of yours $subject = 'ikwerkthuis.be inloggegevens introductie film'; // change subject $text = 'Beste $NameOfSender, Welkom bij ikwerkthuis.be. Hieronder vind U de logingevens voor het bekijken van de introductiefilm: Adres: http://ikwerkthuis.be/index.php/introductie Gebruikersnaam: introductie Paswoord: film2012 %DataOfForm% Wij nemen spoedig contact met u op. Met vriendelijke groeten, Het ikwerkthuis.be team IP: $IP Date: $Date Time: $Time'; // change text mail($email, $subject, $text, 'From: '.$emailadd.''); // send another one out header("Location:$success_page_name"); } ?> |