milov.nl

Interaction design • webdevelopment • web art • photography

milov.nl : forum : coding : '[php] refresh problem'

[php] refresh problem huphtur, 020421 03:31
i produced lil 'guestbook' php script. when refresh is pressed after a submit, i get IE alert: "The page cannot be refreshed without resending the information... etc etc. Retry/Cancel" Retry resubmits the form. Any idea how to resolve this?

(this is prolly the simplest problem in the book, but im drawing a big blank here, so i accept all flames heh)
sc-66-27-2-18.socal.rr.com
Re: [php] refresh problem milov, 020421 10:25
header("Location: $HTTP_REFERER");
 
kf-nawij-tg01-0274.dial.kabelfoon.nl
Re: [php] refresh problem huphtur, 020421 18:08
hrm.. took me a while to figure this one out
(since im absolute beginner)
but i put php in same page as the form
so got "cannot add header" warnings
now i split up the php from the page
the form now sends data thru seperate php
and in the php i put the header()
it works! even with an anchor!
sc-66-27-2-18.socal.rr.com
Re: [php] refresh problem mados, 020422 14:50
All you have to do is to check if the submitted guestbook entry is equal to the entry submitted last. If they are, simply ignore the detected reload. This way no header() or something like that is needed. A reload will be ignored, regardless whether it was intentional or not.
193.174.8.65
Re: [php] refresh problem kutte, 020525 04:35
whats about:

ob_start();
header ("Location: $HTTP_REFERER");
ob_end_flush();
exit();

dint try it, but should do it?
12-6.K.dial.o-tel-o.net
c c, 020818 03:13
c
pc-30-231-3.apoquindo.pc.metropolis-inter.com
Re: [php] refresh problem tip.nl,jjmb,Jack, 020827 14:16
Same problem, but de solution gives this message:

Warning: Cannot add header information - headers already sent by (output started at /home/httpd/www.name.nl-80/html/guestbook.php:62) in /home/httpd/www.name.nl-80/html/guestbook.php on line 180

Wat can be wrong?
It works locally (localhost)

Thanks in avance,
Jack.
gw-ehv03.pnl.philips.com
Re: [php] refresh problem wanadoo.nl,philbert,Philbert, 020827 15:02
I am not versed in PHP, but the same problem appears in ASP.
If you try to redirect a page after you have already sent data back to the browser (probably something like 'echo' in php) the web server is not able to do that.

Most of the ASP pages I have that include a form, submit to a special submit page, which does not send data back to the browser. After processing the data submitted in the form, the submit page then redirects to the original asp page with the form on it.

e.g.: form_page.asp -> submits to form_page_submit.asp -> redirects back to form_page.asp

The form values are lost in the redirect, so if you refresh the page, it will not complain about resubmitting the form values.
p2033197.net.upc.nl
Re: [php] refresh problem tip.nl,jjmb,Jack, 020827 18:53
Thanks, that works. I had thinked of that way, but thought it would be possible with one file. I can live with two files to keep retransmission of the data in separate files.

Jack.
gw-ehv05.pnl.philips.com
Re: [php] refresh problem haikal, 020913 12:57
dsfsdf
202.185.237.20
Re: [php] refresh problem rediffmail.com,manish_agrawal012,manish Agrawal, 020919 11:29
Add a line like this in the <head> section of your page:

<META HTTP-EQUIV=Refresh CONTENT="X; URL=<?php print $PHP_SELF ?>">

Where X is number of seconds before the page refreshes.




202.88.149.154
Re: [php] refresh problem me, 020927 14:42
try changing the form element method="post" to method="get" this will make the contents of the submitted form go into the url, but will not cause the refresh prompt box to appear!
stockade.saltstone.com
Re: [php] refresh problem glpunk, 020927 18:42
I have the same problem.... when refresh the page reinsert the data.... I use form action $PHP_SELF (I need that...). exist anyway to not reinsert data with this method???? maybe "kill" or "destroy" the $HTTP_POST_VARS?? Tkx
siemens.com.ve
Re: [php] refresh problem artypants, 021002 08:44
Isn't there some way to call a refresh of the refering page from the submit function page?
adsl-64-171-1-187.dsl.sntc01.pacbell.net
Re: [php] refresh problem Lea, 021127 13:25
Hi ,

I have also the problem when I click on refresh button and I got the message "the page cannot be refreshed without resending the information..."

I read here Jack's recomendition about spesial submit page. So u wont to implement this way but I don’t know how do it,

I work with html and JSP pages.

Please if you can xplain me how do it ?
I hope to your help,



Thanks and Regards,

Lea


r-255-56.aquanet.co.il
Re: [php] refresh problem dafdfadfadfa, 021220 20:38
Hello,world
131.95.141.239
Re: [php] refresh problem MacNasty, 030107 09:34
try var_dump() see www.php.net
hnllhi1-ar1-4-65-051-100.hnllhi1.dsl-verizon.net
Re: [php] refresh problem Slowhand, 030108 09:45
My gustbook is 2 part.
index.php with form that action with fetch.php
fetch.php is can handle header("Location: index.php") to call back the GB. This prevent the multimessages reloading problems.
I hope you help this...
adsl-121-81.adsl-pool.axelero.hu
Re: [php] refresh problem lgsoftindia.com,vikramb,Vikram B, 030116 14:01
This message states that it will re-send information, whether or not you filled anything out. This is because many websites have something called "hidden fields," which the user cannot see. These fields hold dynamic values that are used throughout the site. In order to reload/refresh the page, the information must be re-sent to the server, regardless of whether or not you have entered anything. Please click "retry," and the reload/refresh process will complete, and bring you to the requested page.

203.200.20.35
Re: [php] refresh problem test, 030121 00:50
test
212.2.218.37
this board serdar, 030121 00:54
im looking for like this php board (sign and view on the same page). how can i find the sources ?
212.2.218.37
this board 3dfiction, 030121 00:55
im looking for like this php board (sign and view on the same page). how can i find the sources ? please mail to me.
212.2.218.37
Re: [php] refresh problem enereco.com,davide.barbaresi,Davide, 030226 15:41
Hi, i have the same problem...when i submit my dates in a form, the program produces this warning message: Warning: Cannot add header information - headers already sent by (output started at /var/www/html/dbvendor/config.php:48) in /var/www/html/dbvendor/insert_comic.php on line 23.....i see your solutions but i can't resolve my problem...Can you have another solutions for me?.....
host114-85.pool8173.interbusiness.it
Re: [php] refresh problem It's normal, 030514 22:27
It's juste the way the protocol http header hang the informations you submit, using post will do this warning because while you refresh, they resend the information again. The best solution is to use 2 pages as you did and that all. No more problem guys.
MTL-ppp-145994.qc.sympatico.ca
Re: [php] refresh problem Savut, 030514 22:29
all the header() must be used before you output any html code. You can't use the header() function after beginning to write something. You have to solve it.
MTL-ppp-145994.qc.sympatico.ca
Re: [php] refresh problem ultrapro.ro,stefandima,Stefan, 030618 13:18
I see the problem solve (i guess) in phpmyadmin from phpdev (the version it's not important, in all). But i dont find out how. From what i read above nobody realy solve the problem.
The: header("refresh: X, ....") it's not good because it's make refresh after X secs.
The: var_dump ..... no coment
It's easy, all i want to know it's how i realise in php if it's the first run or it's a refresh.
Thx.
www.ultrapro.ro
Re: [php] refresh problem lightcrawler.com,dan,Dan, 030625 06:45
I've read this whole post and here is my solution to having a page refresh without resending the information:

At the end of my script I set $HTTP_POST_VARS and $_POST arrays to empty arrays.

ie:
$HTTP_POST_VARS = array();
$_POST = array();

Depending on what version of PHP you use you really only need to set one of the two POST variables but I set both just in case.

This has worked for me but please let me know by email if there is any problem with what i'm doing.

Dan
h24-80-117-148.vf.shawcable.net
Re: [php] refresh problem 1, 030728 09:33
1
netcache1-acld.auckland.clix.net.nz
Re: [php] refresh problem hmm, 030729 23:27
hmmm
ext-pub-18.nait.ab.ca
Re: [php] refresh problem sadfsdf, 030806 13:59
sadfsd
80-28-205-25.adsl.nuria.telefonica-data.net
Re: [php] refresh problem tomx, 030810 22:35
headers already sent..
that's isn't real problem..
you simply cannot use echo or print in script included at first..
AND after the "?>" tag in included script there cannot be any newline or
space symbol..
that's all folks.. (it works :))

sykora.cc.apnet.sk
Re: [php] refresh problem tomx, 030810 23:09
:%s/that's isn't/that's not/g

excuse my horrible english :)
sykora.cc.apnet.sk
Re: [php] refresh problem dAniel, 030813 09:34
@Dan: unsetting $_POST does not work (at least with IE).

But it's simple:
use $_SESSION to store the $_POST data!
for action of the form put a very small .php file like this:


-- data_submit.php --
<?php
include('inc_topmost.php');
$_SESSION['myPOST']=$_POST;
header('location:data.php');
exit;
?>
---------------------
 

this reloads the page (header command), but without POSTed data. But we have stored it in $_SESSION and can access and unset it. Great, huh? :)

you simply have to use sessions for this, which offer a lot of flexibility besides this. use
session_start()
  for that (see php.net manual, if you're not familiar to it).

nice scripting!
dsl-082-082-125-158.arcor-ip.net
Re: [php] refresh problem dAniel, 030813 09:37
you'll better put a space into the location header:
header('location: data.php');
 

IIRC I read about browsers who need exactly one space there.

dsl-082-082-125-158.arcor-ip.net
Re: [php] refresh problem brent, 030816 01:36
Use Dan's solution. I've been working at this for a while, came across his solution, and no more duplicate entries after refresh.

(put at end of code)
$HTTP_POST_VARS = array();
$_POST = array();

65.124.71.2
Re: [php] refresh problem dora, 030816 01:51
hi,
I'm making a shopping cart with php and sessions, and the problem with refreshing the page appears when the user is at the stage when the basket needs to updated (product added or removed / quantity changed etc.).
Say, the user adds a product to the basket (using two separate .php pages) and after the basket contents are updated and shown, the user hits the refresh button. Although there is no form involved in the process (just anchor links carrying the data) the refresh causes the insert/update to happen once more.
Now, obviously I've added a "check-to-see-if-it's-already-inserted" function, but still the user gets a message similar to "this product is already inserted", when they really haven't requested such a thing.
The "meta refresh" just makes the page refresh in a loop.

Has anybody got any other ideas?

cheers,
dora
vdp174.ath19.cas.hol.gr
Re: [php] refresh problem yahoo.com,rag_chirag,chirag modi, 030822 06:33
how to make progress status in php?
202.56.222.213
Re: [php] refresh problem dumbo, 030829 15:01
well i don't know if you want it in ur php page or not but go to internet options, advanced, then scroll down 2 bottom. click the very last thing *warn if forms submittal is being redirected*
mcf4.wc.optusnet.com.au
Re: [php] refresh problem sdf, 030915 12:08
fdsfdsfsdfsdf
abn137-237.interaktif.net.tr
Re: [php] refresh problem hotmail.com,kimdemanila,kaye, 030923 10:27
I have this problem about refreshing a jsp but I still need the value of the variable that has been passed from another page. You see everytime I refresh the jsp the value is lost, can I refresh the jsp without losing the value passed from other pages? tnks in advance.
203.131.86.189
Re: [php] refresh problem alex, 030929 03:45
hm...may be problem with browser???
gw1.farpost.ru
Re: [php] refresh problem asf, 031007 16:29
asf
207.61.253.178
Re: [php] refresh problem matus from Slovakia, 031016 05:45
the same problem

so whats the trick to solve it???

the array function didn't work

I don't wanna separate my code though

its been only few weeks I'm working with php... please help

go to "http://ala.jklm.sk", they have it done... I don't know how!
ts46-02-qdr2053.knnwck.wa.charter.com
Re: [php] refresh problem matus from Slovakia, 031016 05:47
ups, its http://ala.jklmn.sk
ts46-02-qdr2053.knnwck.wa.charter.com
Re: [php] refresh problem hotmail.com,rajneeshgarg,Rajneesh Garg, 031017 08:36
Regarding the refresh notification, I simply followed the following steps:
On page1, I submitted the form so as to capture the page's information. Use get method while submitting the form.
I didnt receive any message following this. If get method is not used, and default method (post method) is used, refresh notification may appear.
203.200.76.85
Re: [php] refresh problem iascoot, 031105 07:36
hey, i use:
header('Status: 302 Moved Temporarily');
header("Location: index.php"); /* Redirect browser */
in the submit code, refreshes perfectly
proxy2.ihug.co.nz
Re: [php] refresh problem rightgen.com,himakumar,hima kumar, 031117 14:01
i included one file into another file and included file have sends headers,another file also have but i can't remove them and it is giving "headers already sent"
what can i do?
203.145.191.118
Re: [php] refresh problem Adeesha Wickremasin…, 031122 20:13
Hey people,
cut and paste the following code in the very top of your 'header' page. This only applies to PHP pages and I have only tried it on MSIE. Also this method won't be applied to php shopping cart pages because credit card #'s will be stored in cache.
But I used this method to search something on the database from my main page. The search results displays on a different page. And there I have 'next','previous' links to go back and forth through the results.
Also you should use 'action=post' in the main page and 'action=get' in the display page.
Try it out! it worked for me!
(make sure you have a common page called header.php or something and paste the following code there. Then call header.php from any page).
---------------------------------------------------
---------------------------------------------------
header("Cache-Control: yes-store, yes-cache");
header("Pragma: yes-cache");
header("Cache-control: private"); //to not lose filled out information
//<META HTTP-EQUIV="Expires" CONTENT="-1">
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); //a past date(can use -1)
----------------------------------------------------------
----------------------------------------------------------

24.68.202.119
serg ergserg, 040108 20:33
sergserg$HTTP_POST_VARS = array();
$_POST = array();
d51523A02.kabel.telenet.be
Re: [php] refresh problem Jimmy, 040108 23:25
Use javascript location().
ip68-100-99-45.dc.dc.cox.net
Re: [php] refresh problem thawat, 040112 08:59
dfdd
208.147.1.2
Re: [php] refresh problem hotmail.com,gibimpaul,Gibi Paul, 040126 14:59
I did the following change at my php.ini file
session.cache_limiter =nocache
session.cache_expire = -10
This has worked but please let me know by email if there is any problem with this.

Gibi Paul
:)

62-128-165-10.iwayafrica.com
Back Button Hacking yahoo.com,NathanKayy,Nathan, 040206 08:22
I have a JSP page with some <input...> fields and a submit button. I had written a simple servlet and using that in this JSP page, to insert the captured data in database. JSP pages uses POST.

After entering data and pressing submit. The data gets captured and JSP page refreshes with all fields blank.. waiting for new data.

The problem is... Now, if i do a page Refresh..
I get the typical MS message "The page cannot be refreshed without resending the information...blah blah ok cancel".
And pressing OK...reenters the old data taking it from the request object, though the screen is blank before a refresh.

Any comments is highly appreciated.

Thanks
Nathan
edsiapl01.eds.net
Re: [php] refresh problem nub, 040209 04:26
Just testing this websites submit form :P
ppp152-254.lns1.cbr1.internode.on.net
[empty] dans sweet page, 040305 13:55
dans sweet page
80-218-119-224.dclient.hispeed.ch
Re: [php] refresh problem Gareth Morris, 040309 13:01
There is some terrible advice in this thread.
I had this problem and solved it like this:

1) change the action="" attribute of your <form> tag from action="myform.php" to action="myform.php?add=1". You can still use method="POST" and POST all your other variables.

2) at the top of your php script, you can do a check for:

// ** START SCRIPT ** //

if ($_GET["add"]=="1") {
// .. place your update/insert logic here ..
// redirect to the same page, but without the add=1 variable
header("Location: myform.php")
// stop processing of script after redirect
exit();
}

// normal display of page should go here - this is where the redirect above will redirect to.

// ** END SCRIPT ** //



The way this works is that the form submits to a page with URL of yourpage.php?add=1 - and then it redirects to yourpage.php. The users browser thinks these two are actually different pages, but they are not, and it is very simple to check what stage we are at (submit or normal display) using the logic given above.

Hope that helps.
brailsford.plus.com
Re: [php] refresh problem Ray, 040320 01:25
Gareth:

Finally a voice of clarity! Your solution worked perfectly! Thanks a bunch. Actually my open source uses the same method but my mind went blank...

Thanks
Ray
216.148.100.53
Re: [php] refresh problem yahoo.com,jamie_venk,Venkat, 040417 16:53
Hi ,

i have got this problem also.. although i dont work on php... i have a page which contains 4 frames which are made by a servlet .. for some operation another small popup is generated where data is filled and sent back to the old frame... but on clicking on save IE gives me this warning of not been to send the data and asks to refresh the page... i cannot change it to GET request as it is a part of a huge framework and it may affect other pages.. where do i add the META CONTENT refresh tag if it will solve the problem. in the popup form or in the main frame.. please help me out as it is requires a very quick solution.... thanx.. any other way is also welcome....
61.95.140.114
Re: [php] refresh problem aol.com,nykornman,joe, 040520 05:55
ok does anyone know a browser with no character limits in the URL...REAOSN WHY SOMETIMES "GET" WONT WORK IS BECUASE THE CHARACTER LIMIT IN THE URL IS LIMITED AND IT WILL ONLY WORK IN A "POST" METHOD. IF ANYONE KNOWS A BROWSER WITH NO LIMIT PLEASE EMAIL ME NYKORNMAN@AOL.COM
ool-182fa856.dyn.optonline.net
Re: [php] refresh problem ygh, 040523 19:27
dcx tgyfv
lux.ee
Re: [php] refresh problem Muhameed, 040529 17:44
Everyone go to www.php.net , i am sure it will solve your problemos. Gracias mucho.

Muhammeed
62-128-167-127.iwayafrica.com
Re: [php] refresh problem Leif, 040611 22:45
Hey, the guy who has written this page must know how to do it... Where is he in all this?
k5n5m9.cm.chello.no
Re: [php] refresh problem Mathieu \'P01\' HEN…, 041118 11:14
:\ those ukrainian spammers
AAmiens-152-1-3-30.w83-192.abo.wanadoo.fr
Re: [php] refresh problem service, 041129 11:59

Your guestbook is very nice. Thenk you
design123-2.kiev.farlep.net
Re: [php] refresh problem Milo, 041129 12:20
Oh, so that's why you spammed it 10 times?
81.23.239.48
Re: [php] refresh problem Mathieu \'P01\' HEN…, 041129 14:54
^__^ is it so hard to think some people loves you enough to post 10 messages in a row ?

Watching the IP, I see that's still that moron from Ukrain.
AAmiens-152-1-16-212.w83-192.abo.wanadoo.fr
Re: [php] refresh problem Calm_Pear, 041130 16:36
blah... again no real question... :-/
g193094.upc-g.chello.nl
Re: [php] refresh problem Calm_Pear, 041207 13:58
hey Milo, can't you just block this morons ip address in a htaccess file?
g193094.upc-g.chello.nl
Re: [php] refresh problem inharry, 041210 20:40
Gareth: you are the man! :)

Your solution worked perfectly!
I used header("location: ".$PHP_SELF) instead of header("location: myform.php")

Thanks
pantera.mecon.gov.ar
Re: [php] refresh problem hotmail.com,sakkiidit,markov, 041223 19:11
I've tried that, but I'm still having trouble; I' really new at this so that's why: it'd help if I had an actual PHP book instead of online tutorials! Well, this is the last thing I need to do anyhow.

I've probably got the code messed up somehow.

In the first page, I have:
action="res_testflight.php?add=1"

In the second (php) page:
//connect to server and choose flight database
include("data/data.php");
$conn = mysql_connect($servername, $username, $password) or die("Could not connect: " . mysql_error());
$db=mysql_select_db("res_flight", $conn);

if ($_GET["add"]=="1") {//this works! It gets the value from previous page!

//code that collects the user's input $_POST['userinput'] from the previous page and goes through choices, etc.
.
.
.it prints out "echo's" necessary stuff
.
header("Location: res_testflight.php");
exit();

mysql_close();


hsdbes206-163-224-169.sasknet.sk.ca
Re: [php] refresh problem test, 050322 18:15
I used before any html is outputted but after youve done stuff with you data
if (is_int($insert_book)) {
ob_start();
header ("Location: ".$HTTP_REFERER."?suc=1");
ob_end_flush();
exit();
}
and then in the html body before your form or errors appears just then use
<? if ($_GET['suc'] == 1) { ?>
<table width="80%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3" class="head">Book inserted into datebase</td>
</tr>
</table>
<? } else { ?>
....html <form> etc
phoneresearch.de
Pages: 1