Jump to content

Can a script post to another script without browser interaction?


kael.shipman

Recommended Posts

I've been looking for this for a while. I have a site that uses post variables for navigating the "processors" section. For example, index.php?p=1 runs the appropriate page. If I post something to index.php?p=1 where $_POST['process'] = 1 and $_POST['action'] = 'chng_name', it knows by the first post variable to include the Processors file, then it knows by the second variable what it needs to do with the rest of the post data. It processes the appropriate data and continues to load the same page again. However, I've run into a few times where it would be nice to be able to keep a page running on an array that the user submits without having to have the user resubmit stuff every time. I know that's confusing, but here's another example:

 

<?php
$files = $_POST['files'];
//$files is an array submitted by the user telling the parser which files to parse

$file = current($files);
if ($file) {
//Parse the file. This takes a long time, so if I loop it, sometimes PHP times out before it gets to the end of the array.
//Instead of looping through the array, just remove the first element and repost it
array_shift($files);
post_redirect($_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'],array('process'=>1,'action'=>$_POST['action'],'files'=>$files));
//The above is a made up function that posts the array in the second argument to the script in the first. This is what I need to find.
}

//output rest of the page
?>

 

Essentially, it should be like using header('Location: newPage.php'), but with post variables included.

 

Oh, and for the record, I'm not looking for a way to solve this problem; that part is easy with a different approach. I'm looking to see if there's any way to solve it in this particular manner.

 

Thanks!

Link to comment
Share on other sites

Hm. I admit, from my brief overview, that looks like a little bit more than what I'm after. I don't doubt that I could do it that way, but it seems there should be a more elegant solution than calling up a whole new library simply to pass post data along. Maybe not, though. I understand that the application I'm after isn't exactly standard, and therefore I guess I shouldn't expect a standard solution.

 

Thanks for the suggestion, and if there are any other suggestions out there, send them my way!

 

-kael

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.