themistral Posted February 7, 2008 Share Posted February 7, 2008 Guys, this is driving me mental! Just to let you know, this isn't down to code being sent to the browser before the headers. Basically, I have a form - the form action processes a function which should insert the information into the database and redirect to a thank you page. The info is inserted but the redirect doesn't work... I have tried hard coding it but I still can't seem to make it work... This is beginning of my page <?php session_start(); ?> <?php include('includes/functions.inc.php'); ?> <?php // process add review if (isset($_POST['but_add_review'])) { funcReviewAdd('http://www.myurl.com/page-name.html'); } The function is function funcReviewAdd($redirect) { // connect to the database funcConnect(); // add to the database the code here works - insert query // redirect page header('Location:'.$redirect); } I have echoed $redirect and is getting the right value parsed, it's just the redirect not working... Please help!! Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 7, 2008 Share Posted February 7, 2008 Turn on full php error reporting and then check your web server log for errors. Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/#findComment-461288 Share on other sites More sharing options...
themistral Posted February 7, 2008 Author Share Posted February 7, 2008 Thanks for the reply! No errors showing up in the server log. Added error_reporting(; to my code but nothing showing up. Any other ideas? Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/#findComment-461327 Share on other sites More sharing options...
Daniel0 Posted February 7, 2008 Share Posted February 7, 2008 error_reporting( will only show errors of type E_NOTICE (cf. http://php.net/manual/en/ref.errorfunc.php#errorfunc.constants). Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/#findComment-461329 Share on other sites More sharing options...
themistral Posted February 7, 2008 Author Share Posted February 7, 2008 I tried with error reporting 8191 but still got nothing back... Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/#findComment-461332 Share on other sites More sharing options...
resago Posted February 8, 2008 Share Posted February 8, 2008 try adding exit just to see if its a buffer thing. Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/#findComment-461357 Share on other sites More sharing options...
haku Posted February 8, 2008 Share Posted February 8, 2008 add exit; after header('Location:'.$redirect); Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/#findComment-461441 Share on other sites More sharing options...
themistral Posted February 8, 2008 Author Share Posted February 8, 2008 OK tried adding exit. I now get a blank page returned - the same URL as the code, not the redirected URL. Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/#findComment-461587 Share on other sites More sharing options...
haku Posted February 8, 2008 Share Posted February 8, 2008 You put exit after the redirect right? Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/#findComment-461588 Share on other sites More sharing options...
themistral Posted February 8, 2008 Author Share Posted February 8, 2008 I did I put it in the function after header('Location:'.$redirect); exit; Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/#findComment-461592 Share on other sites More sharing options...
brandensmith1 Posted February 8, 2008 Share Posted February 8, 2008 its exit(); Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/#findComment-461595 Share on other sites More sharing options...
themistral Posted February 8, 2008 Author Share Posted February 8, 2008 Changed to header('Location:'.$redirect); exit(); and still shows a blank page... I'm going to comment out all functions not required and see if there is a weird problem (maybe whitespace or something) in my functions file. Will let you know what happens! Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/#findComment-461605 Share on other sites More sharing options...
linuxlord Posted February 8, 2008 Share Posted February 8, 2008 Try to avoid any output[even white spaces] before passing header. else use ob_start() & ob_end_flush() Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/#findComment-461621 Share on other sites More sharing options...
Wolphie Posted February 8, 2008 Share Posted February 8, 2008 I had this same problem when using headers with sessions. Try removing session_start(); then trying the re-direct on it's own Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/#findComment-461623 Share on other sites More sharing options...
aschk Posted February 8, 2008 Share Posted February 8, 2008 What error are you getting? Or is it just not redirecting an all? Create a page called simple.php and put the following into it (no whitespace please): <?php // Redirect to google.com header("Location: http://www.google.com"); ?> Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/#findComment-461644 Share on other sites More sharing options...
Zane Posted February 8, 2008 Share Posted February 8, 2008 to get all errors you need E_ALL error_reporting(E_ALL); Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/#findComment-461646 Share on other sites More sharing options...
Daniel0 Posted February 8, 2008 Share Posted February 8, 2008 its exit(); exit() is a language construct and not a function. Therefore, omission of the brackets is allowed. Link to comment https://forums.phpfreaks.com/topic/89970-headers-help-needed/#findComment-461703 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.