Jump to content

[SOLVED] quick question


gevo12321

Recommended Posts

you'd have to use javascript:

 

function gotoUrl(url) {
    document.location = url;
}

function startTimer() {
    setTimeout("gotoUrl('<?php echo $url; ?>')", 5000);
}

 

then just call startTimer to start the 5 sec count down.

hope this helps.

Link to comment
Share on other sites

From the manual at http://ca.php.net/manual/en/function.header.php, it's Refresh not redirect

 

I found the following code to help me refresh a page or really redirecting to a page after a certain number of secionds.  (I'm using php 5.x)

 

<?php

print(" <p align=\"center\"> User Not Found</p><br><br>");  // err msg 

header('Refresh: 3; url=index.html'); // waits 3 seconds & sends to homepage

?>

 

Link to comment
Share on other sites

so...

 

if i want to insert data into a database

 

and after i click the submit button

 

i want the page to say

 

"thank you. you will be redirected back in 5 seconds"

 

do i put the redirect after i close my mysql connection?

 

No, you'll get a 'headers already sent error because you've sent data to the browser.

Link to comment
Share on other sites

ok

 

when i click the submit button, this code takes action:

<?php
require_once('../connect.php');
$newsnumber = $_POST[newsnumber];
$date1 = $_POST[date1];
$title = $_POST[title];
$news = $_POST[news];
mysql_query("UPDATE `news` SET `date` = '". $date1 . "', `title` = '".$title."', `news` = '".$news."'
WHERE newsnumber = '" . $newsnumber . "'");
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\">
<html>
<body>
News Archive has been edited
<br>
You will be redirected back to the news page in 3 seconds.
<br>
Thank You
</body>
</html>
";
mysql_close($link)
?>

 

how do i modify this code to redirect me after 3 sec?

Link to comment
Share on other sites

nvm i got it

 

thx

 

il just use the html meta redirect

 

like this:

<?php
require_once('../connect.php');
$newsnumber = $_POST[newsnumber];
$date1 = $_POST[date1];
$title = $_POST[title];
$news = $_POST[news];
mysql_query("UPDATE `news` SET `date` = '". $date1 . "', `title` = '".$title."', `news` = '".$news."'
WHERE newsnumber = '" . $newsnumber . "'");
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\">
<html>
<head>
<meta http-equiv=\"Refresh\" content=\"2; url=enews.php\">
</head>
<body>
News Archive has been edited
<br>
You will be redirected back to the news page in 2 seconds.
<br>
Thank You
</body>
</html>
";
mysql_close($link)
?>

 

thank you

Link to comment
Share on other sites

From the manual at http://ca.php.net/manual/en/function.header.php, it's Refresh not redirect

 

I found the following code to help me refresh a page or really redirecting to a page after a certain number of secionds.  (I'm using php 5.x)

 

<?php

print(" <p align=\"center\"> User Not Found</p><br><br>");  // err msg 

header('Refresh: 3; url=index.html'); // waits 3 seconds & sends to homepage

?>

 

 

Oops.. I use that function lots... I should have know that.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.