ziedinjsh Posted March 7, 2011 Report Share Posted March 7, 2011 (edited) Saistībā ar citu jautājumu man radās šāds: Kā var atvēr popup kurā parādās pievienošanas rezūltāts? <?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_id']; $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){ // šeit atveras popup document.getElementById('succsess').style.display='block';document.getElementById('fade').style.display='block' }else{ // šeit atveras popup document.getElementById('error').style.display='block';document.getElementById('fade').style.display='block' } } 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_id']."'>".$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(); ?> Kā tas ir panākāms!? Edited March 7, 2011 by ziedinjsh Quote Link to comment Share on other sites More sharing options...
m8t Posted March 7, 2011 Report Share Posted March 7, 2011 alert();? ps. - ieteikums -> mācies JQuery. Noderēs ;) Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted March 7, 2011 Author Report Share Posted March 7, 2011 nu aler tas ir windows logs.. bet kā atvert šo popup ko izmantoju lapā? document.getElementById('succsess').style.display='block';document.getElementById('fade').style.display='block' Quote Link to comment Share on other sites More sharing options...
m8t Posted March 7, 2011 Report Share Posted March 7, 2011 <script type="text/javascript"> <!-- YOUR SCRIPT HERE --> </script> ? Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 7, 2011 Report Share Posted March 7, 2011 Kā izskatās Tavs "pop-up"? =/ Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted March 7, 2011 Author Report Share Posted March 7, 2011 neiet vienalga.. vai arī es nepareizi daru kaut ko! <?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(); ?> popup: function openpopup($title){ echo "<div id='$title' class='wstyle'>"; echo "<div class='popup'>"; echo "<div class='content'>"; echo "<a href = \"javascript:void(0)\" onclick = \"document.getElementById('$title').style.display='none';document.getElementById('fade').style.display='none'\"><img class='close' src='img/close.png'></a>"; } function closepopup(){ echo "</div>"; echo "</div>"; echo "</div>"; } Quote Link to comment Share on other sites More sharing options...
wintermute Posted March 7, 2011 Report Share Posted March 7, 2011 <script type="text/javascript"> <!-- YOUR SCRIPT HERE --> </script> Šitā nav īsti labi. Būtu jābāt: <!-- priekš HTML5 --> <script src="/path/tp/your.js"></script> <!-- priekš XHTML 1.0 Strict --> <script src="/path/tp/your.js" type="text/javascript"></script> Un pilnīgi noteikti NE ŠITĀ echo "<a href = \"javascript:void(0)\" onclick = \"document.getElementById('$title').style.display='none';document.getElementById('fade').style.display='none'\"> <img class='close' src='img/close.png'></a>"; Ziediņš, varbūt ir pienācis laiks beidzot iemācīties javascript : http://eloquentjavascript.net/index.html Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted March 8, 2011 Author Report Share Posted March 8, 2011 Tas ko noraadiiji "Un pilnīgi noteikti NE ŠITĀ " tas ir links kursh aizver popup.. tads jau vinjsh var palikt.. bet kaa tad atver popup mysql dautu ievadiishanas rezultaataa?? Ar funkciju? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.