Jump to content

Waiting Time


balkan7

Recommended Posts

Hi guys

i have created code when user send msg for new msg must wait 30 minuts, so i wanna show minuts for expire whiout refrshing browser, only that can be whit ajax, but im new whit ajax.

 

code is:

<?php if (isset($_POST['send'])){

$user = $userdata['user_name'];
$zelba = stripinput($_POST['muzicka_zelba']);
$date = time() + 1800;

if ($zelba != ""){
      $result = dbquery("INSERT INTO ".$db_prefix."zelbi VALUES ('', '$user', '$zelba', '12', '0', '$date')");
if ($result) echo "<script type=\"text/javascript\">alert(\"".$locale['007']."\");</script>";
      } else {
$error = $locale['005'];
}
}
$result = dbquery("SELECT * FROM ".$db_prefix."zelbi WHERE korisnik='".$userdata['user_name']."'");
$find = dbrows($result);
//if ($find != 0){
  $row = dbarray($result);
  $date_now = time();
  $minus = $row['date'] - $date_now;
  $expire = date("i", $minus);
  $check_date = date("d-m-Y H:i:s", $row['date']);
	$now = date("d-m-Y H:i:s");
	if ($now < $check_date){
		//$expire = $check_date - $now;
		echo "<br><div align='center'>".$locale['040']."<b>".$expire."</b>".$locale['041']."</div><br>";
 } else {
echo $locale['002']."<br /><form method='post' action='$PHP_SELF'>
<input type='hidden' name='send'>
<table align='center' cellpadding='0' cellspacing='0'>
<tr>
<td class='tbl'>".$locale['003']." <b>".$userdata['user_name']."</b></td>
</tr>
<tr>
<td class='tbl'>".$locale['004']." ".$error."<br /><textarea name='muzicka_zelba' cols='50' rows='4' class='textbox'></textarea></td>
</tr>
<tr>
<td align='center'>
<br />
<input type='submit' class='button' value='".$locale['008']."' onClick=\"this.disabled=true; this.form.submit; this.value='".$locale['009']."'\" /></td>
</tr>
</table>
</form>\n";
  } ?>

Link to comment
https://forums.phpfreaks.com/topic/108996-waiting-time/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.