pass Form data into PHP array

Hi all,

I’ve been away from PHP and web developing for the last 7 years. Now I’m designing my own website for my own company.

There will be a ‘kind of’ payment page. Which will get basic information from a form and redirect the user to a safe payment site.

I’ve been dying to figure out what I am doing wrong for the past 3 hours. I’ve asked unlce google every possible question I can think of for the right answer, but, alas, all is left to ask it in a forum, and just sit and hope…

I’ve got this code :

[php]

<? setlocale( LC_TIME, 'ru_RU.UTF-8', 'russian' ); $thisDay = strftime("%B %Y"); $private_key = "*************************"; $public_key = "i************"; $amount = $_POST["amount"]; $comments = $_POST["comments"]; $results = array( 'version' => 3, 'action' => 'pay', 'public_key' => $public_key, 'amount' => "500", (this works) 'currency' => 'UAH', 'description' => "test", (this works) 'type' => 'buy', 'language' => 'ru' ); $data = base64_encode(json_encode($results)); $signiture = base64_encode( sha1( $private_key . $data . $private_key, 1 ) ); ?>

[/php]

which then uses this form to pass the data to the site :

<form method="POST" accept-charset="utf-8" action="https://xxxxxxxxxxxxxxxxxxx" />
 
<input type="hidden" name="data" value="<? echo $data; ?>" />

<input type="hidden" name="signature" value="<? echo $signiture; ?>" />

<input type="text" name="clientNo" style="width:30px;" />

<input type="text" name="clientName" style="width:300px;" />

<input name="amount"  type="text" style="width:50px; text-align:center;" />

<input type="text" name="comments" style="width:300px; text-align:center;" />

<input type="image" src="images/payment-01.png" name="btn_text" /> 

</form>

his works well but the array I use is just the data I entered myself. I have to get the Amount and Description

But when I change the php code to this it just does not get the data from the form :

[php]<?
setlocale( LC_TIME, ‘ru_RU.UTF-8’, ‘russian’ );

$thisDay = strftime("%B %Y");

$private_key = “*************";
$public_key = "i
”;

$amount = $_POST[“amount”];
$comments = $_POST[“comments”];

$results = array(

'version'		=>	3,
'action'		=>	'pay',
'public_key'	        =>	$public_key,
'amount'		=>	$amount, (this does not work)
'currency'		=>	'UAH',
'description'	        =>	$comments, (this does not work)
'type'			=>	'buy',
'language'		=>	'ru'

);

$data = base64_encode(json_encode($results));

$signiture = base64_encode( sha1( $private_key . $data . $private_key, 1 ) );

?>[/php]

I am pretty sure that it is so simple that I look stupid. But… I can not resolve this problem on my own…
I tried this :

[php]<?
setlocale( LC_TIME, ‘ru_RU.UTF-8’, ‘russian’ );

$thisDay = strftime("%B %Y");

$private_key = “*************";
$public_key = "i
”;

if (isset($_POST[“amount”])) / (this does not work)

{

$amount = $_POST[“amount”];
$comments = $_POST[“comments”];

$results = array(

'version'        =>    3,
'action'        =>    'pay',
'public_key'     =>    $public_key,
'amount'        =>    $amount, (this does not work)
'currency'        =>    'UAH',
'description'     =>    $comments, (this does not work)
'type'            =>    'buy',
'language'        =>    'ru'

);

$data = base64_encode(json_encode($results));

$signiture = base64_encode( sha1( $private_key . $data . $private_key, 1 ) );

}

?>[/php]

Not working…

Please help!

Thanks in advance !!!

[php]if (isset($_POST["amount"])) / (this does not work)[/php]

What happens? It has to do something.

Are you sure it is doing what it should and you are just not doing anything with what it did?

it returns an empty value for $amount and $comments

To be honest, I have no idea what I am doing wrong.
The first version where there are no variables, just entered array, it works fine.

I’m still working on it…
(((

I don’t see a return statement there at all.

do a print_r on data AND on $_POST to see what is has, compared to what it should have.

Sponsor our Newsletter | Privacy Policy | Terms of Service