sKunKbad Posted June 22, 2007 Share Posted June 22, 2007 Within my script I have: $whatever = $_POST['whatever']; $whatever2 = $_POST['whatever2']; These were from a form that the user filled out. Alot of stuff happens to $whatever and $whatever2 within my script, but at the end of the script I need $whatever and $whatever2 to get passed as $_POST data to http://www.someotherscript.com/script.php. This data can not be $_GET data in the URL. It must be passed as $_POST data. I know how to use standard HTML forms, but I don't know how to do this. Please help. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 22, 2007 Share Posted June 22, 2007 if this page doesn't have any content you can change header locations and the post variables will be intact on the header change Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 22, 2007 Share Posted June 22, 2007 this is what i use, sub in your function returns as a test or just an aways do <?php if ($passed == "yes") { exit(require('process2.php')); } ?> Quote Link to comment Share on other sites More sharing options...
Wildbug Posted June 22, 2007 Share Posted June 22, 2007 http://us2.php.net/manual/en/function.stream-context-create.php#72017 See stream_context_create() and http_build_query(). You'll be able to use streams to POST data. Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted June 22, 2007 Author Share Posted June 22, 2007 what if the posted data name has changed, or if the value of the posted data changed at some point in the script? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 22, 2007 Share Posted June 22, 2007 so are you saying you want to take the data a person inputs modify it on one page and then input to tables on a second page? if you don't mind me asking why the 2 page deal? Quote Link to comment Share on other sites More sharing options...
Wildbug Posted June 22, 2007 Share Posted June 22, 2007 You're submitting to a script which expects POST form data, right? So post it using the functions named above. The script doesn't give a rat's ass what changes the data went through. You can define what name you wish to give the data when POSTing, and it should agree with the form elements the script expects, but you probably know that already. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 22, 2007 Share Posted June 22, 2007 another idea i've got is if you want to keep this secreative stuff use a session and pull it back from $_REQUEST and users can manually move headers or auto move header localations Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted June 22, 2007 Author Share Posted June 22, 2007 ok ok, what it is is i have an email form on my website that has a radio button a user can check if they want to be added to our email list. For a long time I have been viewing the emails, and manually adding the people to my email database. I also have a host supplied form script that can add the users to the email database, and I'm trying to automate it. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 22, 2007 Share Posted June 22, 2007 um if you can't write a basic mysql insertion script you might want to learn php a bit better before you tackle this Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted June 22, 2007 Author Share Posted June 22, 2007 $name = 'John Doe'; $email = 'johndoe@nobody.net'; //this is the array of name=>value that need to POST array('Name'=>"$name", 'Email'=>"$email", 'DeliveryFormat'=>'HTML', 'Password'=>'RandomNumber', 'SID'=>'{CDFEB2A7-0B0C-4541-A50B-CC975DDB114A}') I've been trying, but I'm in a bit of a rush, any help would be greatly appreciated Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted June 22, 2007 Author Share Posted June 22, 2007 my server says that fopen is disabled, so I'm looking for another way to do this Quote Link to comment Share on other sites More sharing options...
Wildbug Posted June 23, 2007 Share Posted June 23, 2007 See this example using file_get_contents(). Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted June 23, 2007 Author Share Posted June 23, 2007 I used curl. It was super easy. I found a PDF online that was very imformative: http://www.phpit.net/article/using-curl-php/2/?pdf=yes Here was the code I came up with: <?php if ($aCleanedValues['opt-in'] == 'Y'){ $name = $aAllRawValues['realname']; $email = $aAllRawValues['email']; $url = "http://myemaildatabase.php?ID=abcdefg"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); // set url to post to curl_setopt($ch, CURLOPT_FAILONERROR, 1); //needed for some reason curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 31s curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //so you dont see the process, it just happens before the redirect curl_setopt($ch, CURLOPT_POST, 1); // set POST method curl_setopt($ch, CURLOPT_POSTFIELDS, array('Name'=>"$name", 'Email'=>"$email", 'DeliveryFormat'=>'HTML', 'Password'=>'RandomNumber', 'NewsletterListID'=>'123', 'JoinType'=>'Online', 'SID'=>'{CDFEB2A7-0B0C-4541-A50B-CC975DDB114A}')); // add POST fields curl_exec($ch); // run the whole process curl_close($ch); } ?> Quote Link to comment Share on other sites More sharing options...
Wildbug Posted June 23, 2007 Share Posted June 23, 2007 Yeah, you could use cURL. In fact, I was surprised no one had mentioned it yet. For simple stuff, I would use the stream method, though. If all this is on your own site, can't you just modify the "I want your e-mails" form to directly update the database instead of redirecting the input to another form? Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted June 23, 2007 Author Share Posted June 23, 2007 Yeah, you could use cURL. In fact, I was surprised no one had mentioned it yet. For simple stuff, I would use the stream method, though. If all this is on your own site, can't you just modify the "I want your e-mails" form to directly update the database instead of redirecting the input to another form? The "I want your emails" form already directly updates the database, I just wanted the "Send us an email" form to do it too. When using the "Send us an email" form, you are given a choice to subscribe to our emails, and now it automatically updates the database. I could never figure out the streaming. With the information provided in the curl example above, can you show me how you would have done it? 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.