Support » Plugins » PHP header problem

  • Resolved fourninjadeveloper


    header('Location: somesite.php?num=0');

    I’ve been working on a custom WordPress Plugin for months. And I finally thought I was done until this problem hit me. This part of the plugin works in the background so I will need to send data dynamically to a PHP page. However the header command is not working, I’ve been trying to figure this out for a couple weeks and I’ve gotten no where. Am I missing something or do I need to go another route?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator keesiemeijer



    Have you tried it with wp_redirect():

    Yes and it didn’t work. I have the page using file_put_contents in a log so if the data is being sent the php page. However when I take the link out the code and paste into the web browser; it works fine.

    Moderator keesiemeijer



    Without seeing the full code there is not much we can do to troubleshoot.

    Make sure you don’t output anything before the redirect.

    Do you think file_put_contents command is causing an issue?

    function check($data)
    /* function checks parser and than parse the information and send it to the actions folder. */
    $pattern = '|X-Original-To: (.*)|i';
    /* retrieving sql statement */
    $test = checkparsers();
    $flag = 0;
    $par = "";
    $parse ="";
    $i = 0;
    /*Database connection*/
    /*Checking Database for match*/
      preg_match_all($pattern, $data, $out, PREG_PATTERN_ORDER);
         $matches = explode(': ',$out[0][0]);
    while($result = mysql_fetch_array($res))
         if($matches[1] == $result[$i])
            /*set flag to one*/
            $flag = 1;
            /*Database connecting take out*/
             while($result2 = mysql_fetch_array($res)){
             /*building array to pass to parsing function*/
             $type = $result2[4];
               $src = $result2[5];
               if($src == 'body')
                   /*This should split the entrie email into two parts*/
                   $split = preg_split("Content-Transfer-Encoding:", $data);
                   $parse = $split[1];
               /*This gets the header information*/
               if($src == 'email')
                   $split = preg_split("Content-Transfer-Encoding: 7bit", $data);
                   $parse = $split[0];
               if($src != 'email' && $src != 'body')
                   $parse = $data;
            if($type == 'beforeafter')
                $par = 'beafter';
               $parse = beafter($parse, $result2);
            if($type == 'reg')
                $par = 'regexpress';
                $parse = regexpress($parse, $result2);
        if($type == 'fnot')
                $par = 'fnot';
                $parse = fnot($parse, $result2);
        if($type == 'cal')
                $par = 'calculate';
                $parse = calculate($parse, $result2);
        /*Database connection taken out*/
             /*looping through the files. */
    /* This is a test*/
                    header('Location: somesite.php?num=0');
            $i = $i + 1;
        /*psssing information to to the action files*/
        /*Handling action files*/
          file_put_contents("/home/amuser1/public_html/","functions.php passed\n" , FILE_APPEND);

    Here is the function. I took out the database connection for security purposes.

    I solved the issue.

    Apparently when using the header command it requires a browser and since I need this to happen in the background the header command will not work. After some researching and trial and error I came across another way of using the file_put_contents. It’s hard for me to explain it thoroughly but some example code and solution can location here.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PHP header problem’ is closed to new replies.