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! Link to comment https://forums.phpfreaks.com/topic/100057-passing-on-_post-variables/ 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 Link to comment https://forums.phpfreaks.com/topic/100057-passing-on-_post-variables/#findComment-511637 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']; ?> Link to comment https://forums.phpfreaks.com/topic/100057-passing-on-_post-variables/#findComment-511644 Share on other sites More sharing options...
Northern Flame Posted April 8, 2008 Share Posted April 8, 2008 look up cURL() Link to comment https://forums.phpfreaks.com/topic/100057-passing-on-_post-variables/#findComment-511645 Share on other sites More sharing options...
DanFTW Posted April 8, 2008 Author Share Posted April 8, 2008 thanks a lot Link to comment https://forums.phpfreaks.com/topic/100057-passing-on-_post-variables/#findComment-511646 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 Link to comment https://forums.phpfreaks.com/topic/100057-passing-on-_post-variables/#findComment-511648 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); } ?> Link to comment https://forums.phpfreaks.com/topic/100057-passing-on-_post-variables/#findComment-511656 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! : ) Link to comment https://forums.phpfreaks.com/topic/100057-passing-on-_post-variables/#findComment-511670 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? Link to comment https://forums.phpfreaks.com/topic/100057-passing-on-_post-variables/#findComment-511703 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. Link to comment https://forums.phpfreaks.com/topic/100057-passing-on-_post-variables/#findComment-511704 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).... Link to comment https://forums.phpfreaks.com/topic/100057-passing-on-_post-variables/#findComment-511718 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']; */ ?> Link to comment https://forums.phpfreaks.com/topic/100057-passing-on-_post-variables/#findComment-511725 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.