Editing: group_chat.php
Kembali
<?php include ("koneksi.php"); date_default_timezone_set('Asia/Kolkata'); $ts=date('y-m-d h:ia'); $tdatepick=date('y-m-d'); $tpick=date('h:ia'); //if ($idp == ""){ $idp $idp = $_GET['idp']; $iddriver = $_GET['iddriver']; if (isset($_POST['reset'])){ $conn->query("delete from diruachat where idP=$idp or idD=$iddriver"); $conn->query("delete from pickup where idP=$idp or idD=$iddriver"); } if (isset($_POST['pickup'])){ $sql = "select * from pickup where idP=$idp"; $query = $conn->query($sql); $row=$query->fetch_assoc(); if (mysqli_num_rows ( $query) > 0){ $conn->query("update pickup set time_pickup='".$tpick."' where idP='".$idp."' or idD='".$idp."'"); }else{ $conn->query("insert into pickup (idP,idD,date,time_pickup) values ('".$idp."','".$iddriver."','".$tdatepick."','".$tpick."')"); } if ($row['Price'] == "" ){ $mspick = "Total Fee ($): ".number_format($row['Price'],2); }else{ $mspick = "Total Fee ($):0"; } } if (isset($_POST['submit']) or (isset($_POST['pickup']))){ $idp = $_GET['idp']; $iddriver = $_GET['iddriver']; /* Attempt MySQL server connection. Assuming you are running MySQL server with default setting (user 'root' with no password) */ $link = mysqli_connect("server135.web-hosting.com", "mdilafbe", "E1SgCDAf2qfr", "mdilafbe_dirua"); //$link = mysqli_connect("localhost","root", "", "otaxi"); // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } // Escape user inputs for security $un= mysqli_real_escape_string( $link, $_REQUEST['uname']); $m = mysqli_real_escape_string( $link, $_REQUEST['msg']); if (!$m){$m = $mspick ;} // Attempt insert query execution $sql = "INSERT INTO diruachat (idP, message, date, idD) VALUES ('$un', '$m', '$ts', '$iddriver')"; if(mysqli_query($link, $sql)){ ; } else{ echo "ERROR: Message not sent!!!"; } // Close connection //mysqli_close($link); } ?> <html> <head> <style> *{ box-sizing:border-box; } body{ background-color:#abd9e9; font-family:Arial; } #container{ width:auto; height:auto; background:white; margin:0 auto; font-size:0; border-radius:5px; overflow:hidden; } main{ width:auto; height:auto; display:inline-block; font-size:15px; vertical-align:top; } main header{ height:100px; padding:5px 5px 5px 5px; background-color:#FFF; } main header > *{ display:inline-block; vertical-align:top; } main header img:first-child{ width:24px; margin-top:8px; } main header img:last-child{ width:24px; margin-top:8px; } main header div{ margin-left:90px; margin-right:90px; } main header h2{ font-size:25px; margin-top:5px; text-align:center; color:#FFFFFF; } main .inner_div{ padding-left:0; margin:0; list-style-type:none; position:relative; overflow:auto; height:auto; background:#FFF; background-position:center; background-repeat:no-repeat; background-size:cover; position: relative; border-top:2px solid #fff; border-bottom:2px solid #fff; } main .triangle{ width: 0; height: 0; border-style: solid; border-width: 0 8px 8px 8px; border-color: transparent transparent #58b666 transparent; margin-left:20px; clear:both; } main .message{ padding:10px; color:#000; margin-left:15px; background-color:#58b666; line-height:20px; max-width:90%; display:inline-block; text-align:left; border-radius:5px; clear:both; } .txtmsg{ padding:10px; color:#000; margin-left:15px; background-color:#FFF; line-height:10px; width:140%; display:inline-block; text-align:left; border-radius:5px; clear:both; } main .triangle1{ width: 0; height: 0; border-style: solid; border-width: 0 8px 8px 8px; border-color: transparent transparent #6fbced transparent; margin-right:20px; float:right; clear:both; } main .message1{ padding:10px; color:#000; margin-right:15px; background-color:#6fbced; line-height:20px; max-width:90%; display:inline-block; text-align:left; border-radius:5px; float:right; clear:both; } main footer{ height:auto; padding:20px 30px 10px 20px; background-color:#666; } main footer .input1{ resize:none; border:100%; display:block; width:120%; height:55px; border-radius:3px; padding:20px; font-size:13px; margin-bottom:13px; } main footer textarea{ resize:none; border:100%; display:block; width:120%; height:55px; border-radius:3px; padding:20px; font-size:13px; margin-bottom:13px; margin-left:20px; } main footer .input2{ resize:none; border:100%; display:block; width:50%; height:45px; border-radius:3px; padding:10px; font-size:13px; margin-bottom:5px; margin-left:100px; color:white; text-align:center; background-color:black; border: 2px solid white; } } main footer textarea::placeholder{ color:#ddd; } </style> <body onLoad="show_func()"> <div id="container"> <main> <span onClick="document.getElementById('container').style.display='none'; window.history.back();" class="close" title="Close">×</span> <header> <div> <h4 align="center">DIRUA CHAT <br>(Please click Pick-Up when done)</h4> </div> </header> <script> function show_func(){ var element = document.getElementById("chathist"); element.scrollTop = element.scrollHeight; } </script> <form id="myform" method="POST" > <div class="inner_div" id="chathist"> <?php $query = "SELECT * FROM diruachat where (idP=$idp or idp=$iddriver) AND idD=$idp or idD=$iddriver "; $run = $conn->query($query); $i=0; while($row = $run->fetch_array()) : if($i==0){ $i=5; $first=$row; ?> <div id="triangle1" class="triangle1"></div> <div id="message1" class="message1"> <span style="color:white;float:right;"> <?php echo $row['message']; ?></span> <br/> <div> <span style="color:black;float:left; font-size:10px;clear:both;"> <?php echo $row['idP']; ?>, <?php echo $row['date']; ?> </span> </div> </div> <br/><br/> <?php } else { if($row['idP']!=$first['idP']) { ?> <div id="triangle" class="triangle"></div> <div id="message" class="message"> <span style="color:white;float:left;"> <?php echo $row['message']; ?> </span> <br/> <div> <span style="color:black;float:right; font-size:10px;clear:both;"> <?php echo $row['idP']; ?>, <?php echo $row['date']; ?> </span> </div> </div> <br/><br/> <?php } else { ?> <div id="triangle1" class="triangle1"></div> <div id="message1" class="message1"> <span style="color:white;float:right;"> <?php echo $row['message']; ?> </span> <br/> <div> <span style="color:black;float:left; font-size:10px;clear:both;"> <?php echo $row['idP']; ?>, <?php echo $row['date']; ?> </span> </div> </div> <br/><br/> <?php } } endwhile; ?> </div> <footer> <table> <tr> <th> <input class="input1" type="hidden" id="uname" name="uname" placeholder="From" value="<? echo $idp; ?>"> <input class="input1" type="hidden" id="iddriver" name="iddriver" placeholder="From" value="<? echo $iddriver; ?>"> </th> <th> <input type="text" pl class="txtmsg" id="msg" name="msg" placeholder="Type your message" /> </th> <th> <input class="input2" type="submit" id="submit" name="submit" value="Send"> <input class="input2" type="submit" id="pickup" name="pickup" value="Pick-Up"> <input class="input2" id="reset" name="reset" type="submit" value="Cancel"> </th> </tr> </table> </footer> </form> </main> </div> </body> </html>
SIMPAN PERUBAHAN