DanFTW Posted April 7, 2008 Share Posted April 7, 2008 How do I pass on $_POST variables to a third page? ex. the form is on-->dropdownform.php the action submits it to-->formhandler.php--> How can I pass it on to another page? Thanks in advance! Quote Link to comment Share on other sites More sharing options...
kevin7 Posted April 8, 2008 Share Posted April 8, 2008 you can create a hidden form type and set the value to the $_POST variables, so if the user clicked on submit button, it will pass the data to the next page. or, the urgly way, put your data as a parameter in the url e.g, formhandler.php?name=kevin&age=17...... cheers Quote Link to comment Share on other sites More sharing options...
Caesar Posted April 8, 2008 Share Posted April 8, 2008 Or...on page two, you can redefine the post variable. It will post to page three just fine. Example: Page#2.. <?php $_POST['caca'] = $_POST['caca']; ?> Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted April 8, 2008 Share Posted April 8, 2008 look up cURL() Quote Link to comment Share on other sites More sharing options...
DanFTW Posted April 8, 2008 Author Share Posted April 8, 2008 thanks a lot Quote Link to comment Share on other sites More sharing options...
DanFTW Posted April 8, 2008 Author Share Posted April 8, 2008 <?php $_POST['caca'] = $_POST['caca']; ?> and in this ^^^ where is the page to where it will pass on the ['caca'] part too? lmao Quote Link to comment Share on other sites More sharing options...
Caesar Posted April 8, 2008 Share Posted April 8, 2008 You're probably better off using form processing classes or functions, rather than seperate pages. Example... <?php class forms { function process($vars) { //Do your thang } } $f = new forms; if(isset($_POST['submit']) && $_POST['submit'] != '') { $f->process($_POST); } ?> Quote Link to comment Share on other sites More sharing options...
kevin7 Posted April 8, 2008 Share Posted April 8, 2008 or, you can use session variable to store you data... there are plenty of ways! : ) Quote Link to comment Share on other sites More sharing options...
DanFTW Posted April 8, 2008 Author Share Posted April 8, 2008 ah!!! session, didn't think of that! haha i'm a beginner you can obviously tell =P. Or is this possible? multiple actions? send to 2 pages? Quote Link to comment Share on other sites More sharing options...
DanFTW Posted April 8, 2008 Author Share Posted April 8, 2008 ^^^ in the html form part of the thing. Quote Link to comment Share on other sites More sharing options...
kevin7 Posted April 8, 2008 Share Posted April 8, 2008 erm... not so sure about that, i dont think so you can do that in the form alone, you might the help of javascript (AJAX).... Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted April 8, 2008 Share Posted April 8, 2008 once again, you're better off with cURL() let me show you an example: <?php function makeVars($array){ $x = 0; foreach($array as $key => $val){ $vars[$x] = $key . '=' . $val; $x++; } $variables = implode("&", $vars); } function Post($vars,$url){ $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,1); #curl_setopt($ch,CURLOPT_UPLOAD,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$vars); curl_exec($ch); curl_close($ch); } // enter your post data here: $postdata = array("caca" => "value", "key" => "val"); // enter as many values as you wish $url = "http://www.website.com/script.php"; // where you want to post the data to makeVars($postdata); Post($variables, $url); /* IN THE URL THAT IS RECEIVING THE DATA, PUT THIS CODE: echo $_POST['caca']; echo "<br />"; echo $_POST['key']; */ ?> Quote Link to comment 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.