473,394 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to refresh only a part of the script instead of the entire page

Hello All,

I have written a script that sends a mail to the administrator of the website at the end of the day. To do this i am checking whether system time is equal to the set time (this is the time at which i want to send the mail to the admin), and if the condition satisfies, i am sending the mail.

But i am stuck with this. To send a mail, it should check each time whether the system time equals set time or not, if it equals send a mail or else do not send a mail to the admin. For this, each time the page needs to be refreshed.

But if i refresh it each time, the index.php of the site also gets refreshed as the mailing script is contained in it. I do not want that to happen as this should not be known to the user. (hidden from the user).

So, can anyone help me out with this?

Regards,
Dream2rule
Aug 29 '07 #1
7 1825
pbmods
5,821 Expert 4TB
Heya, Dream.

To accomplish this, you will need to use AJAX or iframes.
Aug 29 '07 #2
thanks but i would want to mail admin without the user's knowledge who's browsing the site. How do i do that?

Here's the code:

[PHP]

<?php
ob_start();
//header("refresh:01;");
require "Mail.php";

// get the current timestamp into an array
$timestamp = time();
//echo strftime('%H:%M %A %d %b',$timestamp)."<br>";

$date_time_array = getdate($timestamp);

$hours = $date_time_array['hours'];
$minutes = $date_time_array['minutes'];
$seconds = $date_time_array['seconds'];
$month = $date_time_array['mon'];
$day = $date_time_array['mday'];
$year = $date_time_array['year'];

// use mktime to recreate the unix timestamp
// adding 5 hours to $hours and 30 minutes to $minutes
$systimestamp = mktime($hours + 5,$minutes+30,$seconds,$month,$day,$year);
$systime=date("h:i:s A",$systimestamp);
echo "SYS TIME - ".$systime."<br>";
echo strftime('%H:%M %A %d %b',$timestamp)."<br>";

$settimestamp=mktime(13,32,0,date("m"),date("d"),d ate("Y"));
$settime=date("h:i:s A",$settimestamp);
echo "SET TIME - ".$settime."<br>";

//REFRESH HERE EACH SECOND TO CHECK WHETHER THE SYSTEM TIME EQUALS SET TIME

if($systime==$settime)
{
//echo $systime."<br>";
//echo $settime;
$from = "Admin <some_name@some_site.com>";
$to = "Admin <some_name@some_site.com>";
$subject = "Test Mail";
$body = "Hi,\n\nHow are you?";

$host = ""; //smtp host address
$username = "some_name@somesite.com";
$password = "password";

$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject);
$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail))
{
echo("<p>" . $mail->getMessage() . "</p>");
}
else
{
echo("<p>Message successfully sent!</p>");
}
}
?>

[/PHP]
Aug 29 '07 #3
pbmods
5,821 Expert 4TB
Heya, Dream.

Are you trying to email yourself a log of all the Users that visited your site during the day?
Aug 29 '07 #4
Yes i am.. i want to send a mail containing the list of users online on my website at 12:00 am everyday. And i want this script to run on the index.php page along with many other scripts and it should be invisible to the users browsing my website.
Aug 29 '07 #5
pbmods
5,821 Expert 4TB
Heya, Dream.

Is it feasible to store these values in a database and then run a cron job to send the email?
Aug 29 '07 #6
Yes the user's ip address and the dates on which they were online are being tracked into a database.

But the issue here is the system time is static(seconds) and the seconds value does not increment without refreshing the page each second. But when i refresh the page entire index.php is refreshed every second which i do not want it to happen.

I tried using using a javascript digital clock script even but again with this,it displays the time but the mail is NOT sent. :( :(

Any alternatives here? Please help....
Aug 30 '07 #7
pbmods
5,821 Expert 4TB
Heya, Dream.

Can you use a cron job to do this? Or is cron access disabled on your server?
Aug 30 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: kindermaxiz | last post by:
I have a php script with a form that insert data in a mysql db and when I click on submit I would like the page to refresh after the insertion, how can I do that? it's a php script that display...
11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
6
by: Matt | last post by:
By using javascript, is it possible to disable the REFRESH functionality (F5 or refresh icon) in a browser? Please advise. Thanks!!
1
by: Marco Maroni | last post by:
How to force image refresh on client browser ? Is ti possible to force the refresh of the same image (tha was changed server-side) to the client, without user press Contrl+F5 in IE ? - Marco
17
by: SamSpade | last post by:
picDocument is a picturebox When I do picDocument.Invalidate() the box paints. But if instead I do picDocument.Refresh() the box does not paint. What does Refresh do. I guessed it did an...
6
by: Bob | last post by:
Hi All, Is the following possible, and if so could someone show me some example code please :o) I have a web page with several iframes, and I want to be able to refresh them only not the...
10
by: phforum | last post by:
Hi, I wrote a PHP page for user input the information to search the database. And the database data will update every second. I want to set the auto refresh to get the data from database every...
5
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi, I used the following code to refresh the parent page, and it works very well (Thanks to Peter Bromberg "). Response.Write("<script language='javascript' type='text/javascript'{...
2
by: =?Utf-8?B?U2lsa0NpdHlGbG9yaWRh?= | last post by:
I have a web page "PgA" with a GridView. I open another page "PgB" in a new window. On PgB, they do some things that affect the underlying data for the GridView on PgA. When the user is done...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.