ziedinjsh Posted March 11, 2011 Report Share Posted March 11, 2011 Sveiki! esmu uztaisījis kaut ko līdzīgu pm systēmai. msg.php <?php session_start(); include("header.php"); include("fcs/functions.php"); if(!isset($_SESSION['user_email'])){ include("login.php"); } else { include("menu.php"); oside(); openside(); echo "<button name='newmsg' value='' class='add-button' onclick = \"document.getElementById('newmsg').style.display='block';document.getElementById('fade').style.display='block'\">Jauna vēstule</button>"; closeside(); cside(); openpage(); $msg_to = $_SESSION['user_email']; $msg = mysql_query("SELECT * FROM messages")or exit( mysql_error() ); while ($data = mysql_fetch_array( $msg)) { echo "<div id='show-msg' onclick=\"location.href='read.php?msg='".$data['msg_id']."'';\">"; echo "<div class='show-from'>".$data['msg_from']."</div>"; echo "<div class='show-title'><a href='read_msg.php?id=".$data['msg_id']."'>".$data['msg_title']."</a></div>"; echo "<div class='show-date'>".$data['msg_date']."</div>"; echo "<div class='fix'></div>"; echo "</div>"; } closepage(); openpopup("newmsg"); include "new_msg.php"; closepopup(); include("footer.php"); } ?> new_msg.php <?php $data = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE user_email='".$_SESSION['user_email']."' LIMIT 1")); $users = mysql_query("SELECT * FROM users"); if(isset($_POST['send_msg'])){ $msg_to = $_POST['msg_to']; $msg_from = $data['user_name']; $msg_title = mysql_real_escape_string($_POST['msg_title']); $msg_text = mysql_real_escape_string($_POST['msg_text']); $msg_date = date("Y-m-d H:i:s"); $msg_status = "0"; $sql = ("INSERT INTO messages (msg_to, msg_from, msg_title, msg_text, msg_date, msg_status) VALUES ('$msg_to', '$msg_from', '$msg_title', '$msg_text', '$msg_date', '$msg_status')"); $result = mysql_query($sql); if($result){ ?> <script language="javascript" type="text/javascript"> document.getElementById('succsess').style.display='block';document.getElementById('fade').style.display='block'; </script> <?php }else{ ?> <script language="javascript" type="text/javascript"> document.getElementById('error').style.display='block';document.getElementById('fade').style.display='block'; </script> <?php } } echo "<div id='new-msg'>"; echo "<form method='post' action='".$_SERVER['PHP_SELF']."'>"; echo "<p>Kam</p><p><select name='msg_to' class='msgselect'>"; while ($data = mysql_fetch_array( $users )) { echo "<option value='".$data['user_name']."'>".$data['user_name']."</option>"; } echo "</select></p>"; echo "<p>Tēma</p> <p><input type='text' name='msg_title' class='msgtitle'></p>"; echo "<p>Saturs</p> <p><textarea name='msg_text' class='msgtext'></textarea></p>"; echo "<p><input type='submit' name='send_msg' value='Sūtīt vēstuli' class='msgbutton'></p>"; echo "</form>"; echo "</div>"; openpopup("succsess"); echo "Vēstule veiksmīgi nosūtīta!"; closepopup(); openpopup("error"); echo "Vēstule nav nosūtīta..."; closepopup(); ?> Jautājums ir sekojos.. Ielogojas lietotājs un kā lai panāk to lai rādās tikai viņam atdresētās ziņas nevis visas kas ir mysql ierakstos? Link to comment Share on other sites More sharing options...
ziedinjsh Posted March 11, 2011 Author Report Share Posted March 11, 2011 Pats sapratu kā :) Link to comment Share on other sites More sharing options...
Recommended Posts