Yes I know you are not able to refresh in php, but insert meta tags into an echo statement that can refresh, or use javascript, etc.

The problem is I have tried all these solutions and it still does not work. :(

So I will tell you my problem and hopefully you can help me. :)

I have a page that is used to delete certain images.

You select the image on the MAIN page and then press a DELETE button (input type="submit").

Then the MINOR page is opened up with the details of the image you just deleted.

What I am looking for is when that DELETE button is clicked that it does what it does and then at the end the page is REFRESHED.

So any ideas? Thankyou.

Regards X

not totally sure if this would work but have you tried using

header('Location: script name');

its a nice php way to go to a page, not sure if it would work though.

or you could use a nice bit of JavaScript/AJAX

Oh Sorry i forgot, that reminds me to mention as it might not be noticable.

The php that is used to code the input button uses the code

header("Location: url");

and as we all know we cant use 2 headers in the one input button :(

So any ideas yet? ;)

huh ? When you execute your query, send the header back to the same page. It will work.

<?php
if(isset($_POST['submit'])) {//if delete button is pressed
$id=$_POST['id'];
$q="delete from table where id = '$id'";
mysql_query($q);
header("location: samepage.php");
}
<html>
<body>
<form method="post" action="samepage.php">
<!-- list the images and have a delete button in this form -->
</form>
</body>
</html>

Thats how I do and it always work for me. What do you mean by we cant use 2 headers in one input button ?

that is what confused me, and i was pretty sure that the header would work now i have woken up. but by the sounds of it he/she may have used the submit button to redirect using header (maybe??)

exactly.

I already am using the header to open another page, and I am not able to use it to refresh.

So you get what im trying to do?

Short:
Use header to open up another window.
? to refresh the page.

Check this out. This isn't php refresh. But meta refresh. You can use this to refresh your page. Or even javascript location.href .

Ya I found that on my google search BUT how would I insert that via php?

Because what I thought the code would be didnt work:

Note: Also this refreshs a page every X seconds I just need it to refresh once the DELETE button is clicked.

echo "<meta http-equiv='refresh' content='0'>";

So what you think I should do?

Thanks, Regards X

if($_POST['delete'])) { //delete button is pressed
echo '<meta http-equiv="refresh" content="1;url=yourpage.php">';
} // refresh only if delete button is pressed
?>

dosent work nav....

when i press the button it does nothing but open the new window like it always has, anything I do does not refresh it (actually if i throw a meta refresh in the head section of the html it keeps refreshing every x seconds but again that is useless and annoying) =(

So attempt #2? Thanks =)

try this

if($_POST['delete'])
{
ur code
}
?>
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=urpage.php">

So anyone got any ideas how I can refresh a page?

Im all out of ideas =(

Ok I have news!

I think I have found the source of the problem now...

echo "<meta http-equiv='refresh' content='0;url=test.php'>";

works in another php file.

Now when i use it in this php file it does not!

The only difference is that this page uses a header to redirect it to another page that is opened in a new window, could this be interfering with the refresh(It wouldnt be refreshing the new page instead?)? If so why? how? who? what? when? where? =P Anyways if someone can provide a solution or an alternative way to do things to allow both things to happen I will greatly appericate it.

Regards, X

Well, I still don't know/understand what is the problem in using the header function.

if(true){
header("location: true.php");
} else if(false) {
header("location: false.php");
} else {
 header("location: unknown.php");
}

You can have multiple header function depending upon the result.

Maybe I am explained this bad.

I know you can use multiple header functions BUT I required a new page to be opened (header function + form target="_blank") then I require the page to be refreshed (not the one I just opened the one I just deleted the item from).

Does that explain it better?

Regards, X

PS: I just tested the page by removing header in it and refresh worked... If no one can come up with a solution ill just have to try work something else out but I really dont want to :(

Ive had to opt for the another way of doing things dosent matter too much now. If anyone has found a solution to my old problem let me know

Regards, X

PS: Thanks for all the help people

Ok Problems back again, I just figured out why I cant do plan B so now I require a page to be opened and the page that opened that page be refreshed.

I need help and I dont know why the usual meta refresh is not working =(

So can anyone help? Because I am at a dead end.

Due to me using the header to open a new webpage in a new window I am unable to refresh the page the usual way(uisng meta tag) any ideas? plz plz plz plz

Regards, X

well rather then using a header to open the new window, try using a little bit of javascript to open a new window then your refresh should work

I cant... values are passed through using php hence why I have no choice but to use a header to open the new web page =(

HAI NAV33N..


Thanks a lot for giving this code ....

echo '<meta http-equiv=

If i understand this right,you want to push a delete button which will make a popup window and delete some file,while the popup window has opened you want your source page(the one with the delete button) to be refreshed ?
Try this button maybe this is what you want

<input type="button" name="Delete" value="Delete!"
onclick="setTimeout('location.reload(true)', 3000)"/>

Silly of me to revive this thread, but did you find any solution?

I am looking for a PHP script that allows me to refresh the page I am *currently* on in a function.

Let me explain:

Users of my site will be able to log in from anywhere on it so all login information & processing is handled in a separate file.

So if a member logs in at index.php, the browser would refresh index.php as he logged in.
But if he did the same at randompage.php, the browser would refresh randompage.php & not send him back to index.php .

I just want the page to refresh - not redirect to anywhere else. I'll also need to have to defined as a string/function that can be used with

$_SESSION['login_url']

.

PHP cannot refresh pages.

For your current scripts location you can use $_SERVER

if(isset($_POST['login_buton'])){
 $_SESSION['login_url'] = $_SERVER['PHP_SELF'];
 //do all testing/cleaning/escaping here also do the authentification -> DO NOT OUTPUT ANYTHING
 //if all okay then 
 header("Location: http://www.mysite.com/".$_SESSION['login_url']);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.