Jump to content

Recommended Posts

Well basically here is what I have so far. I have a form where a user inputs things. Then It sends it to a php script which does some work with it. What I want it to do is have a user send enter the stuff in the form, it then gets submited to my script, and my script passes the variables onto another website.

 

Now I already have the variables sent via post to my script. I need them to be sent on to the other website using post too. I have no control over the other website. I just know what variables i have to send. And i do not want the user to have to enter his info all over again just so it gets sent to the other site.

 

So how can i pass along post variables?

 

I asked at another forum and they said i was trying to do something fishy. well im not because:

 

Its a guys website at my school. He just wants an extra layer of security to where u have to go through my site to get to his. Kinda weird i know but he already has it setup on his side and is reluctant to change it. So I already have everything setup accept this. cookies and all that.

I already know it is installed. ok I saw this example on the internet:

 

<?php
$urltopost = "http://somewebsite.com/script.php";
$datatopost = array (
"firstname" => "Mike",
"lastname" => "Lopez",
"email" => "my@email.com",
);

$ch = curl_init ($urltopost);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$returndata = curl_exec ($ch);
?>

 

Well there is an array. And I think that is what gets sent on it looks like. If it is then how do i insert variables in an array.

according to here:

http://us2.php.net/manual/en/language.types.array.php

 

"Using variables as array names no longer works in PHP5."

 

SO is there a way that i can make a variable be pulled as not a variable if you understand what i mean? Like convert a variable into just the text they entered so that way it will work with the array?

ok well i used the code above to send a variable. Well it atleast sends something to the other server because it logs it but it logs nothing. Like i just setup a demo script to test it. the first script logs what the user put in a text file. Then is sopposedly sends that variable to the other script. The other script logs it in a different text file. Both should say this in the text file

test: (whatever was entered in the variable)

 

The first text file is fine. The second text file has just this in it

test:

 

SO what code should i have at the receiving end to actually get the variable that i send?

ok well heres is what im using to send the variables:

 

$test2 = $_POST['testing'];

$urltopost = "http://websitehere/test.php";
$datatopost = array (
$test2,
);

$ch = curl_init ($urltopost);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$returndata = curl_exec ($ch);

?> 

 

I recieve it using

 

$test = $_POST['test2'];

$test3 = "Test: $test";

$file = fopen("test.txt", "a");
fputs($file, "$test3\r\n");
fputs($file, "\r\n");
fclose($file);

 

there you go. What am I doing wrong since the second file isn't receiving the variable.

 

 

For defining the first variable i use a html form.

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.