tags:

views:

36

answers:

3

Hello,

I am working in a form, which is in a hidden script called by Ajax method.
In this php script, I want t submit the information using an URL,using this piece of code:

header("location: https://www.page.com/servlet/?encoding=UTF-8&oid=333&first_name=$first_name&last_name=$last_name");

But the informaton is not submitted.

Any idea?? Thanks in advance.

A: 

edit: use $_GET to retrieve the variables

More about $_GET here

Sotiris
Variables inside double quotes do get parsed as variables if that's what you meant, `{ }` are not necessary.
Tatu Ulmanen
correct. I have read it somewhere, maybe I misunderstood it. So the only he needs is to retrieve data with $_GET?
Sotiris
You will need { } if you're using an array value inline. For example {$array['key1']}.
Fanis
@Fanis thank you for the answer. I edited the post.
Sotiris
A: 

It's not that the code you have given is not working. It's only that maybe the program counter of the system is not going to that destination page or that destination page is not capable yet to retrieve the values.

First of all, your code should be:-

header("Location: https://www.page.com/servlet/?encoding=UTF-8&oid=333&first_name=$first_name&last_name=$last_name");
exit();

The "exit()" function must be used after every "header()" function call, because the "header()" function is meant to redirect the current web page to the desired web page. However the execution of the script continues in the parent page, so you need to use the "exit()" function to stop its execution.

Now in the destination page, you need to write the following code, to retrieve the values:-

<?php
foreach ($_GET as $key => $val) {
    $$key = $val;
}

echo "<br/>Encoding - ".$encoding;
echo "<br/>O ID - ".$oid;
echo "<br/>First name - ".$first_name;
echo "<br/>Last Name - ".$last_name;
?>

So you see I have just used the "$_GET" superglobal variable (click here to know more about it), to retrieve the values send from another page to this destination page.

Hope it helps.

Knowledge Craving
A: 

The thing was the function header()

If I use the function fopen, everything is well redircted:

$handle = fopen("https://www.salesforce.com/.WebToLead?encoding=UTF-8&amp;oid=333&amp;first_name=$first_name&amp;last_name=$last_name", "r");

Thans anyway for your answers

mujer esponja