aithne Posted August 11, 2009 Share Posted August 11, 2009 I am so very frustrated with this issue that I'm so ready to tear my hair out. Or do as this little guy is. So here's my issue. I'm using header location to redirect users from a submitted form to a page that will show them the groups they belong to. When you submit the form, the browser goes to show 'Webpage not found' and in the address bar, the URL looks like this: http://www.site.com/sandbox/%3C?xml version="1.0"?><!DOCTYPE html PUBLIC "-//W3C//D And it continues on the full character length of the address bar. I've been searching Google and Bing to no avail. Anyone have any suggestions on what to look for in this situation? I've never run into an issue like this in my seven or so years of coding. Thanks to anyone who tries!! Quote Link to comment https://forums.phpfreaks.com/topic/169732-php-headers-issue-please-help/ Share on other sites More sharing options...
jarvis Posted August 11, 2009 Share Posted August 11, 2009 Please can you post your code so we can take a look - thanks Quote Link to comment https://forums.phpfreaks.com/topic/169732-php-headers-issue-please-help/#findComment-895443 Share on other sites More sharing options...
aithne Posted August 11, 2009 Author Share Posted August 11, 2009 <? if(!defined('INTERNAL_PAGE')) { define('INTERNAL_PAGE', TRUE); } include 'includes/function.php'; if ($_SESSION['auth'] != 1) { $_SESSION['auth'] = NULL; $_SESSION['name'] = NULL; $_SESSION['userid'] = NULL; header ('Location: http://www.site.com/'); } $thisTribeId = 0; $nowAMember = 0; if (sizeof($_POST) > 0) { //check to see if the name and password are valid. if ($_POST['password'] == '' || $_POST['groupname'] == '') { echo 'Group Name and Password fields cant be blank'; exit; } else { //check to see if this user is already a member of this group //get group id if ($Group->getGroupByName($_POST['groupname']) == 'yes') { //this is a valid group //get group id $thisGroupId = $Group->paramId('get', ''); if ($MyGroups->AlreadyAMember($thisGroupId, $_POST['groupname']) == 'yes') { echo 'You are already a member of this group'; exit; } else { //add userid to the mygroups table $MyGroups->joinGroup($thisGroupId); $nowAMember = 1; $to = $login->getusersEmail($_SESSION['userid']); $subject = 'You joined a Group'; $message = 'You joined the '.$_POST['groupname'].' group.'; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= "To: ".$_POST['email']."\r\n"; $headers .= "From: Site.com <[email protected]>\r\n"; mail($to, $subject, $message, $headers); header ('Location: http://www.site.com/sandbox/ListGroups.php'); exit(); } } else { echo 'Wrong tribe credentials or the group don\'t exist.'; exit; } } exit; } if ($nowAMember == 1) { echo 'You are now a member of the '.$_POST['groupname'].' tribe.'; } // Start Page if(isset($_GET['form']) && $_GET['form'] == 1) { include 'templates/header-popup.html'; include 'templates/join-group.html'; include 'templates/footer-popup.html'; } else { include 'templates/header.html'; include 'templates/my-groups.html'; include 'templates/footer.html'; } ?> Everything works but the header following submission of the form. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/169732-php-headers-issue-please-help/#findComment-895447 Share on other sites More sharing options...
jarvis Posted August 11, 2009 Share Posted August 11, 2009 What happens if you define the url then call that in the header redirect, i.e // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/index.php'; ob_end_clean(); // Delete the buffer. header("Location: $url"); Quote Link to comment https://forums.phpfreaks.com/topic/169732-php-headers-issue-please-help/#findComment-895455 Share on other sites More sharing options...
aithne Posted August 11, 2009 Author Share Posted August 11, 2009 It didn't do anything. The info submitted to the database but the page itself stayed on the form and cleared the data from the fields. Quote Link to comment https://forums.phpfreaks.com/topic/169732-php-headers-issue-please-help/#findComment-895468 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.