/    Sign up×
Community /Pin to ProfileBookmark

Value do not display on next page

Hi guys,

I need your help. When I entering the value number on the form one-line textbox and when I submits the button, the page redirect me to paypal website but there is no value number when I go to the next page.

Here it is the code:

[code]<?php
$p = new paypal_class;
$p->add_field(‘business’, ‘[email protected]’);
$p->add_field(‘first_name’, $_POST[‘first_name’]);
$p->add_field(‘shipping’, ”);
$p->add_field(”, ‘http://www.domain.com/logo.jpg’);
$p->add_field(‘return’, ‘http://www.domain.com/success.php’);
$p->add_field(‘cancel_return’, ‘http://www.domain.com/cancelled.php’);
$p->add_field(‘notify_url’, ‘2’);
$p->add_field(‘cmd’, ‘_xclick’);
$p->add_field(‘currency_code’, ‘USD’);
$p->add_field(‘lc’, ‘US’);
$p->add_field(‘bn’, ‘toolkit-php’);
$p->add_field(‘no_shipping’, ”);
$p->add_field(‘no_note’, ‘1’);
$p->add_field(‘cn’, ‘Comments’);
$p->add_field(‘cs’, ”);
$p->add_field(‘quantity’, ‘1’);
$p->add_field(‘item_name’, ‘Add fund to my account’);
$p->add_field(‘amount’, $_POST[‘deposit.php’, formtext1′]);
$p->add_field(‘item_number’, ‘777’);
$p->add_field(‘undefined_quantity’, ”);
$p->add_field(‘on1’, ”);
$p->add_field(‘os1’, ”);
$p->add_field(‘shipping’, ”);
$p->add_field(‘shipping2’, ”);
$p->add_field(‘handling’, ”);
$p->add_field(‘tax’, ”);
$p->add_field(‘custom’, ”);
$p->add_field(‘invoice’, ”);
$p->add_field(‘first_name’, ‘test’);
$p->add_field(‘last_name’, ”);
$p->add_field(‘address1’, ”);
$p->add_field(‘address2’, ”);
$p->add_field(‘city’, $_POST[‘MyTown’]);
$p->add_field(‘state’, ”);
$p->add_field(‘zip’, ”);
$p->add_field(‘login_email’, ‘[email protected]’);
$p->add_field(‘night_phone_a’, ”);
$p->add_field(‘night_phone_b’, ”);
$p->add_field(‘night_phone_c’, ”);
$p->submit_paypal_post();
$p = new paypal_class;
if ($p->validate_ipn()) {
}
class paypal_class {
var $last_error;
var $ipn_log;
var $ipn_log_file;
var $ipn_response;
var $ipn_data = array();
var $fields = array();
function paypal_class() {
$this->paypal_url = ‘https://www.paypal.com/cgi-bin/webscr’;
$this->last_error = ”;
$this->ipn_log_file = ‘ipn_log.txt’;
$this->ipn_log = true;
$this->ipn_response = ”;
$this->add_field(‘rm’, ‘2’);
$this->add_field(‘cmd’, ‘_xclick’);
}
function add_field($field, $value) {
$this->fields[“$field”] = $value;
}
function submit_paypal_post() {
echo “<html>n”;
echo “<head><title>Processing Payment…</title></head>n”;
echo “<body onLoad=”document.form.submit();”>n”;
echo “<h3>Please wait, your order is being processed…</h3>n”;
echo “<form method=”post” name=”form” action=””.$this->paypal_url.””>n”;
foreach ($this->fields as $name => $value) {
echo “<input type=”hidden” name=”$name” value=”$value”>”;
}
echo “</form>n”;
echo “</body></html>n”;
}
function validate_ipn() {
$url_parsed=parse_url($this->paypal_url);
$post_string = ”;
foreach ($_POST as $field=>$value) {
$this->ipn_data[“$field”] = $value;
$post_string .= $field.’=’.urlencode($value).’&’;
}
$post_string.=”cmd=_notify-validate”; // append ipn command
// open the connection to paypal
if(!$fp) {
$this->last_error = “fsockopen error no. $errnum: $errstr”;
$this->log_ipn_results(false);
return false;
} else {
// Post the data back to paypal
fputs($fp, “POST $url_parsed[path] HTTP/1.1rn”);
fputs($fp, “Host: $url_parsed[host]rn”);
fputs($fp, “Content-type: application/x-www-form-urlencodedrn”);
fputs($fp, “Content-length: “.strlen($post_string).”rn”);
fputs($fp, “Connection: closernrn”);
fputs($fp, $post_string . “rnrn”);
// loop through the response from the server and append to variable
while(!feof($fp)) {
$this->ipn_response .= fgets($fp, 1024);
}
fclose($fp); // close connection
}
if (eregi(“VERIFIED”, $this->ipn_response)) {
// Valid IPN transaction.
$this->log_ipn_results(true);
return true;
} else {
$this->last_error = ‘IPN Validation Failed.’;
$this->log_ipn_results(false);
return false;
}
}
function log_ipn_results($success) {
if (!$this->ipn_log) return; // is logging turned off?
$text = ‘[‘.date(‘m/d/Y g:i A’).’] – ‘;
// Success or failure being logged?
if ($success) $text .= “SUCCESS!n”;
else $text .= ‘FAIL: ‘.$this->last_error.”n”;

// Log the POST variables
$text .= “IPN POST Vars from Paypal:n”;
foreach ($this->ipn_data as $key=>$value) {
$text .= “$key=$value, “;
}
$text .= “nIPN Response from Paypal Server:n “.$this->ipn_response;
$fp=fopen($this->ipn_log_file, ‘a’);
fwrite($fp, $text . “nn”);

fclose($fp); // close file
}
function dump_fields() {
echo “<h3>paypal_class->dump_fields() Output:</h3>”;
echo “<table width=”95%” border=”1″ cellpadding=”2″ cellspacing=”0″>
<tr>
<td bgcolor=”black”><b><font color=”white”>Field Name</font></b></td>
<td bgcolor=”black”><b><font color=”white”>Value</font></b></td>
</tr>”;

ksort($this->fields);
foreach ($this->fields as $key => $value) {
echo “<tr><td>$key</td><td>”.urldecode($value).”&nbsp;</td></tr>”;
}
echo “</table><br>”;
}
}[/code]

The problem that comes with this line:

[code=text]$p->add_field(‘amount’, $_POST[‘deposit.php’, formtext1′]);[/code]

I want to display the value number on the next page when I enter the value number on formtext1 in deposit.php.

Please help!!!!!!!!!!

Thanks,
Mark

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@SyCoSep 29.2008 — $_POST['deposit.php', formtext1']

that's a syntax error, I didn't look at your code in depth but you might want something like

$_POST['deposit.php']

and or

$_
POST['formtext1']

depends what your class requires as the values.
Copy linkTweet thisAlerts:
@mark107authorSep 29.2008 — Thanks for your reply SyCo, I have tried with both methods at different time but unfortunately, none of them are works. All I am trying to do is to sends amount information to paypal and changes the value when I entered on my form.




Hope you can help to get this problem resolve.


Thanks,

Mark
Copy linkTweet thisAlerts:
@mark107authorSep 30.2008 — Any idea????????????? :mad::mad::mad::mad::mad:
Copy linkTweet thisAlerts:
@SyCoSep 30.2008 — like I say it depends what your class requires as the values.

$p->add_field('notify_url', '2');

looks like it needs the field name and the value so for this field

$p->add_field('amount', $_POST['deposit.php', formtext1']);

'amount' you need to know which value is being posted. It's the amount, you might want to be sure about that one!

[code=php]print_r($_POST); [/code]

to see what values are in the POST array.
Copy linkTweet thisAlerts:
@mark107authorSep 30.2008 — Right i get it what you means but i want to enter ANY values number on formtext1 and require for a changes on amount value that have to be matching.


[CODE]$p->add_field('amount', $_POST['deposit.php', formtext1'][/CODE]



I want to do that but it gives me error. Any idea how I can enter any values on formtext1 and makes require for a change on amount at paypal??



If you don't understand what i am trying to do, here it is as example.

For e.g

User enter any value on formtext1

User submits

The amount changed where user entered the value



How i can do that??



Thanks,

Mark
Copy linkTweet thisAlerts:
@mark107authorOct 01.2008 — nobody#????????
×

Success!

Help @mark107 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...