mac007 Posted February 28, 2009 Share Posted February 28, 2009 Hello, all: I am updating a simple table, and after the UPDATE statement gets processed, I want the page to refresh so the fields in the update form get new entries pulled right back. It works all fine, except I cant get the "Record Updated" lconfirmation line to echo also so user knows the update went fine. If I comment-out the "header()" then it echoes fine, but then form values dont refresh... Appreciate the help! This is code I have: <CODE> if (isset($_POST['notepadUpdateNOW'])) { $subject = $_POST['subject']; $note = $_POST['note']; $notedate = $_POST['notedate']; $noteUpdate = mysql_query("UPDATE NOTEPAD SET subject='$subject', note='$note', notedate = $notedate WHERE noteid = $noteRecord") or die('No records updated!'); header("location: #"); echo "Record Updated!"; } </CODE> Quote Link to comment https://forums.phpfreaks.com/topic/147246-why-cant-i-echo-line-after-header-redirect/ Share on other sites More sharing options...
Maq Posted February 28, 2009 Share Posted February 28, 2009 Have you read this sticky yet, HEADERS ERROR? Quote Link to comment https://forums.phpfreaks.com/topic/147246-why-cant-i-echo-line-after-header-redirect/#findComment-772984 Share on other sites More sharing options...
PFMaBiSmAd Posted February 28, 2009 Share Posted February 28, 2009 As soon as your browser receives a header() redirect, it stops rendering the current page and requests the URL in the redirect. Any content you output on a page after a header redirect is just wasting your bandwidth. Quote Link to comment https://forums.phpfreaks.com/topic/147246-why-cant-i-echo-line-after-header-redirect/#findComment-772997 Share on other sites More sharing options...
mac007 Posted February 28, 2009 Author Share Posted February 28, 2009 Thanks PFM, Maq... So, one way I could I echo the line then, would be by storing a "success" or "failed" variable that then I can have it echo on redirected page?? But wouldnt that still be overtaken by the "header()" action?? Quote Link to comment https://forums.phpfreaks.com/topic/147246-why-cant-i-echo-line-after-header-redirect/#findComment-773015 Share on other sites More sharing options...
haku Posted February 28, 2009 Share Posted February 28, 2009 Attach it to the redirected URL. Example: header("Location = page.php?success"); Then on page.php, you check to see if success is set: if(isset($_GET['success'])) { echo "success"; } Quote Link to comment https://forums.phpfreaks.com/topic/147246-why-cant-i-echo-line-after-header-redirect/#findComment-773090 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.