Jump to content

[SOLVED] quick question


gevo12321

Recommended Posts

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
https://forums.phpfreaks.com/topic/57036-solved-quick-question/#findComment-281770
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
https://forums.phpfreaks.com/topic/57036-solved-quick-question/#findComment-281774
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
https://forums.phpfreaks.com/topic/57036-solved-quick-question/#findComment-281777
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
https://forums.phpfreaks.com/topic/57036-solved-quick-question/#findComment-281783
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
https://forums.phpfreaks.com/topic/57036-solved-quick-question/#findComment-281788
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.