WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] PHP header problem (7 posts)

  1. fourninjadeveloper
    Member
    Posted 1 year ago #

    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?

  2. keesiemeijer
    moderator
    Posted 1 year ago #

    Have you tried it with wp_redirect():
    http://codex.wordpress.org/Function_Reference/wp_redirect

  3. fourninjadeveloper
    Member
    Posted 1 year ago #

    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.

  4. keesiemeijer
    moderator
    Posted 1 year ago #

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

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

  5. fourninjadeveloper
    Member
    Posted 1 year ago #

    Do you think file_put_contents command is causing an issue?

  6. fourninjadeveloper
    Member
    Posted 1 year ago #

    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/1funnel.com/public/wp-content/plugins/Paser/actions/actionlog.txt","functions.php passed\n" , FILE_APPEND);
    
    };

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

  7. fourninjadeveloper
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic