Jump to content

PHP Refresh?


Bradley99

Recommended Posts

Didnt' work  :-[

 

This is the PHP code part of the page:

<?php session_start();
include_once"includes/db_connect.php";
include_once"includes/functions.php";
include_once "click_limit.php";

logincheck();
$username=$_SESSION['username'];
$query=mysql_query("SELECT * FROM users WHERE username='$username'");
$fetch=mysql_fetch_object($query);

$query_bf=mysql_query("SELECT * FROM bf WHERE location='$fetch->location'");
$fetch_bf=mysql_fetch_object($query_bf);

if (strtolower($fetch_bf->owner) == (strtolower($fetch->username))){
require_once"bulletCP.php";
exit();
}
$new_time=time()+1800;

$up=mysql_fetch_object(mysql_query("SELECT * FROM site_stats WHERE id='1'"));
$a=mysql_query("SELECT * FROM bf WHERE location='$fetch->location'");
$b=mysql_fetch_object($a);
$user=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$b->owner'"));
//$minus=$user->money - 1000;

if ($user->money < 1000){
mysql_query("UPDATE bf SET owner='None', producing='No' WHERE id='$b->id'");
$crap=1;
}

if ($fetch_bf->time < time() && $fetch_bf->producing == "Yes" && $crap != "1"){
mysql_query("UPDATE bf SET stock=stock+750 WHERE `location`='$fetch_bf->location'");
mysql_query("UPDATE bf SET `time`='$new_time' WHERE `location`='$fetch_bf->location'");
mysql_query("UPDATE users SET `money`=`money`-75000 WHERE username='$b->owner'");
}


if ($fetch->last_bullet > time()){

$left = " ".maketime($fetch->last_bullet)."";

echo "You have dona a bullet deal recently, you have to wait for $left seconds before you can do another!";

exit();

}



if (strip_tags($_POST['check']) && (strip_tags($_POST['amount']))){
$amount=intval(strip_tags($_POST['amount']));
if ($amount == 0 || !$amount || ereg('[^0-9]',$amount)){
print "You cant buy that amount.";

}elseif ($amount != 0 || $amount || !ereg('[^0-9]',$amount)){

$costs = $fetch_bf->price * $amount;
if ($costs > $fetch->money){
echo "You do not have enough money";
} elseif ($costs <= $fetch->money){
$nmoney=$fetch->money - $costs;
if ($fetch_bf->stock < $amount){
	echo "Not that many bullets in the store.";
} elseif ($amount <= $fetch_bf->stock){
	$nbullets=$fetch->bullets + $amount;
	$nstock = $fetch_bf->stock - $amount;

///IF THERE IS NOOOOO OWNER
if ($fetch_bf->owner == "0"){
	mysql_query("UPDATE users SET bullets='$nbullets', money='$nmoney' WHERE username='$username'");


	mysql_query("UPDATE bf SET stock='$nstock', profit='$costs' WHERE location='$fetch->location'");
	echo "Bullets successfully bought.";
////IF THERE IS A OWNER

}elseif ($fetch_bf->owner != "0"){
$fetch_owner=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$fetch_bf->owner'"));
	$new_owner=$fetch_owner->money + $costs;

	mysql_query("UPDATE users SET bullets='$nbullets', money='$nmoney' WHERE username='$username'");

	mysql_query("UPDATE users SET money='$new_owner' WHERE username='$fetch_bf->owner'");

	mysql_query("UPDATE bf SET stock='$nstock', profit='$costs' WHERE location='$fetch->location'");
	echo "Bullets Successfully Bought.";
    $time= time() + 1800;
mysql_query("UPDATE users SET last_bullet='$time' WHERE username='$username'");

}
}}
}

}



?>

Link to comment
https://forums.phpfreaks.com/topic/225544-php-refresh/#findComment-1164617
Share on other sites

Line 6 of BF.php is the code you posted. Functions is just the basic functions of the website, Doesn't have header anywhere inside it though?

 

Start of functions file:

<?php
session_start(); 
include_once "db_connect.php";
$username=$_SESSION['username'];
echo "<link rel=stylesheet href=includes/in.css type=text/css>";
?>
<link rel=stylesheet href=includes/in.css type=text/css>
<link rel=stylesheet href=in.css type=text/css>
<?
$query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1");
$info = mysql_fetch_object($query);
$don=mysql_num_rows(mysql_query("SELECT * FROM donaters WHERE username='$username'"));
$langs=mysql_fetch_object(mysql_query("SELECT * FROM user_info WHERE username='$username'"));

Link to comment
https://forums.phpfreaks.com/topic/225544-php-refresh/#findComment-1164680
Share on other sites

Ajax may be the way to go?

I've got a nice script lying around in here  :P

Let me know if intrested.

 

It's a lot of code, in basic you update the div with the time you'll give it.

I use it all the time @ work with our own message system

 

Don't really understand that? Sorry.

 

I'm just lost as to why it only updates when someone views the page.

Link to comment
https://forums.phpfreaks.com/topic/225544-php-refresh/#findComment-1164695
Share on other sites

Oh, I think I know what you mean. You want php to produce these bullets every 30 minutes, but not depend on a user to view a page? If so, you need to look into cron jobs.

oOo I get what he's goin' for now.  You've just clarified his whole problem in my mind. :P
Link to comment
https://forums.phpfreaks.com/topic/225544-php-refresh/#findComment-1164698
Share on other sites

Oh, I think I know what you mean. You want php to produce these bullets every 30 minutes, but not depend on a user to view a page? If so, you need to look into cron jobs.

oOo I get what he's goin' for now.  You've just clarified his whole problem in my mind. :P

 

Yess! haha! That's what i want!!

 

Unfortunately i am as new as this post to cronjobs. Best get revising!!

Link to comment
https://forums.phpfreaks.com/topic/225544-php-refresh/#findComment-1164703
Share on other sites

Oh, I think I know what you mean. You want php to produce these bullets every 30 minutes, but not depend on a user to view a page? If so, you need to look into cron jobs.

oOo I get what he's goin' for now.  You've just clarified his whole problem in my mind. :P

 

Yess! haha! That's what i want!!

 

Unfortunately i am as new as this post to cronjobs. Best get revising!!

I thought you were sayin' it wasn't loading when you refreshed, but it did when you revisited the page .. and I got lost.  Well, enjoy learning then and best of luck to ya.
Link to comment
https://forums.phpfreaks.com/topic/225544-php-refresh/#findComment-1164707
Share on other sites

1) Upload both .js form the attachment to you're server

2) Ad these lines in you're header

 

<script src="jquery.js"></script>

<script src="updatediv.js"></script>

 

Add this to the header:

<script>

$(document).ready(function() {

          $("#example ajax").load("file witch you want to reload without revisiting.php");

  var refreshId = setInterval(function() {

      $("#example ajax").load("file witch you want to reload without revisiting.php?randval=\'+ Math.random());

  }, 1000);

});

</script>

 

That should do the trick, the page get the data without reloading the page.

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/225544-php-refresh/#findComment-1164711
Share on other sites

Let's say we have an index.php and a data.php.

In data.php you'll retreive all the data.

 

In index.php put the code in the header along with the javascripts.

make in the index.php a div ajax, define the size as you see fit, then the javascripts will keep that div updated with the interval time you specify.

 

 

Link to comment
https://forums.phpfreaks.com/topic/225544-php-refresh/#findComment-1164719
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.