3

I have a form on my site and every time I submit this form..I get a 301 perm, then a 302 redirect, then another 302 redirect. My data is not submitting because of these redirects. I'm having no luck finding these redirects. There is no .htaccess file that is causing this in the root of the directory.

Where do I look to get rid of the redirects? Any tips would be appreciative.

My developer tools on submit goes to 301, 302, 302.

Here is the start of my form.

<form action="index.php?view=ticket_submit" method="POST" name="QContact" runat="vdaemon">

When this submits I have a case statement look for ticket_submit. It's not even getting to ticket_submit because of the var_dump and exit methods. It just goes back to the root index.php file.

private function ProcessView($type){
    $ticket = new Ticket();
    $ticket->CurrentUser = $this->CurrentUser;
    $ticket->TicketUser = $this->CurrentUser;
    $ticket->setBlankTicketHTML();
    $title = 'New ROI';
    $prior_count = count($this->Containers);
    $_SESSION['vdaemon'] = '1';
    if($_SESSION['al'] == 't' && $type['view'] == ''){
        $type['view'] = 'summary';
    }

    switch($type['view']){
        case 'ticket_edit':
            $ticket->ticketid = (int)$this->Request['ticketid'];
            $ticket->TicketUser = array();
            $ticket->fillTicket();

            if(($this->CurrentUser['userid'] != $ticket->TicketUser['userid']) && ($_SESSION['al'] == 't' || $_SESSION['al'] == 'r')){

                $ticket->setViewTicketHTML();
                $title = "Error: You can only Edit items you have created.";
                $_SESSION['vdaemon'] = '0';
            } else {
                $ticket->setEditTicketHTML();
                $title = 'Edit ROI';
                $_SESSION['vdaemon'] = '1';
            }
            break;

        case 'ticket_submit':
            var_dump('test');
            exit();
            $ticket->ticketid = (int)$this->Request['ticketid'];
            $ticket->TicketUser['useremail'] = $this->Request['useremail'];
            $ticket->saveTicket(0);
            $_SESSION['vdaemon'] = '0';             
            if($_REQUEST['viewquick'] == 'quick'){$quick = 'ticket_quick_view';}else{$quick = 'ticket_filed';}
            if($_REQUEST['edit'] == 'yes') {
                echo 'works';
            }else {
                header("Location: ?view=".$quick."&ticketid=".$ticket->ticketid);
                echo 'workss';
            }   
            exit;
            break;
Charles
  • 50,943
  • 13
  • 104
  • 142
wowzuzz
  • 1,398
  • 11
  • 31
  • 51
  • Have you looked in your apache error logs? Maybe a bit of code would could shed a light? – sanders Dec 19 '12 at 21:07
  • Where would the apache error logs be located? – wowzuzz Dec 19 '12 at 21:08
  • @wowzuzz in a folder labled 'logs'. Is this a deployed environment, or a local test environment? What are you using to host it? Do you have any virtual hosts sharing a namespace with this particular site? – Ohgodwhy Dec 19 '12 at 21:11
  • It's a deployed environment. It's on a cloud server using apache and lighttpd. No, there is no virtual hosts. – wowzuzz Dec 19 '12 at 21:12
  • I'm not seeing a logs folder. – wowzuzz Dec 19 '12 at 21:13
  • Are you using a framework like for example CodeIgnitor? Maybe you need to set up routing in the framework for your new view. – jeroen Dec 19 '12 at 21:22
  • 1
    I got the 301 error rid of and the other 302 because I moved it to a new folder. Now its showing me 302. My data won't POST unless the 302 is fixed right? – wowzuzz Dec 19 '12 at 21:37
  • No, I'm not using a framework like CodeIgnitor. – wowzuzz Dec 19 '12 at 21:50
  • This 301/2 change is to prevent a browser refresh from resubmitting data. There was a good post somewhere about it here but can't find it right now. – AKS Dec 19 '12 at 22:41

1 Answers1

1

I ended up fixing it and this is what the cause was.

Three things needed to be fixed.

The first thing was that I needed to fix a reference to a vdaemon library. The path was all screwed up. After that I got rid of a header redirect in two places. One was in a separate folder and one was on my index.php which I totally missed (thought I checked it). It was doing 302 redirects because the headers were there but in different folders throughout the server and on the index.php.

Next time I'll know what to look for. Thanks for everyone's efforts here. :)

Make sure you look for this code first when dealing with these errors

header("Location: http://www.foo.com");
wowzuzz
  • 1,398
  • 11
  • 31
  • 51