mark103 Posted September 29, 2008 Share Posted September 29, 2008 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: <?php $p = new paypal_class; $p->add_field('business', 'me@mail.com'); $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', 'me@mail.com'); $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.1\r\n"); fputs($fp, "Host: $url_parsed[host]\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: ".strlen($post_string)."\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $post_string . "\r\n\r\n"); // 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 . "\n\n"); 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)." </td></tr>"; } echo "</table><br>"; } } The problem that comes with this line: $p->add_field('amount', $_POST['deposit.php', formtext1']); 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 Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/ Share on other sites More sharing options...
Adam Posted September 29, 2008 Share Posted September 29, 2008 $p->add_field('amount', $_POST['formtext1']); try that.. Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-652865 Share on other sites More sharing options...
mark103 Posted September 29, 2008 Author Share Posted September 29, 2008 Thanks for the help, but it is still the same. No value number are showing on the next page. Any idea ??? ??? Thanks, Mark Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-652867 Share on other sites More sharing options...
mark103 Posted September 29, 2008 Author Share Posted September 29, 2008 any idea?? Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-652875 Share on other sites More sharing options...
Adam Posted September 29, 2008 Share Posted September 29, 2008 Hmm, what does your form look like? are you getting the correct $_POST value? try echoing out $_POST['formtext1'] (assuming it's 'formtext1') and just make sure it does have a value.. Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-652876 Share on other sites More sharing options...
mark103 Posted September 29, 2008 Author Share Posted September 29, 2008 what do you mean by how do my form looks like? I am just using a textbox. The name of the textbox i am using is called 'formtext1'. And yes I have correct $_POST value. $p->add_field('amount', echo $_POST['formtext1']; Is that the correct code what you want me to try out?? Thanks, Mark Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-652880 Share on other sites More sharing options...
Adam Posted September 29, 2008 Share Posted September 29, 2008 Nah that's answered my question about the form. the code snippet there will error due to the missing bracket on the end.. I'm assuming then that form you have links to this script. Is it just the "amount" value not showing up on paypal? Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-652881 Share on other sites More sharing options...
mark103 Posted September 29, 2008 Author Share Posted September 29, 2008 Please can you post the correct code cos i am getting confused?? Btw, the amount is the correct name of the form on paypal. I don't understand why it don't show up!!!! Thanks, Mark Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-652883 Share on other sites More sharing options...
Adam Posted September 29, 2008 Share Posted September 29, 2008 Sorry, I'll explain better. At the very top of the script, use: die($_POST['formtext1']); ...straight after the PHP tag. that should show only the value of 'formtext1' .. if it does, remove it and then use the following code to 'add the field'.. $p->add_field('amount', $_POST['formtext1']); My mistake before I didn't see the added "echo" in there... Any luck? Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-652885 Share on other sites More sharing options...
mark103 Posted September 29, 2008 Author Share Posted September 29, 2008 I have input the first code you post die($_POST['formtext1']); but it is incorrect. It make the page goes blank so I have convert it to $_POST['formtext1']; And I have replaced with your second code you post $p->add_field('amount', $_POST['formtext1']); It is still the same. I have no luck. Any idea how to set up the value on the next page that to display it?? Thanks, Mark Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-652889 Share on other sites More sharing options...
Adam Posted September 29, 2008 Share Posted September 29, 2008 If the page is going blank it means there's nothing in $_POST['formtext1'] .. post you form code up aswell.. Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-652895 Share on other sites More sharing options...
mark103 Posted September 29, 2008 Author Share Posted September 29, 2008 here it is: <?php ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>My Profile</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body> <a href="test.php">Back</a> <h1 align="center">Deposit</h1> <input name="formtext1" type="text" style="position:absolute;width:105px;left:351px;top:89px;z-index:0"> <div id="text1" style="position:absolute; overflow:hidden; left:194px; top:92px; width:155px; height:21px; z-index:1"><div class="wpmd"> <div align=right>Add Fund: £ </div> </div></div> <form action="paypal.php" method="post"> <input name="formbutton1" type="submit" value="Submit" style="position:absolute;left:372px;top:120px;z-index:2"> </form> </body> </html> That is the form code. Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-652903 Share on other sites More sharing options...
mark103 Posted September 29, 2008 Author Share Posted September 29, 2008 any idea how to situations and get this resolve?? Thanks, Mark Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-652935 Share on other sites More sharing options...
Adam Posted September 29, 2008 Share Posted September 29, 2008 you have the "formtext1" outside of the form tags... Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-652936 Share on other sites More sharing options...
mark103 Posted September 29, 2008 Author Share Posted September 29, 2008 Yeah so how can I display the value number on next page when I input the value on formtext1?? Please let me know how we can resolve it. Thanks, Mark you have the "formtext1" outside of the form tags... Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-652937 Share on other sites More sharing options...
Adam Posted September 29, 2008 Share Posted September 29, 2008 Put: <input name="formtext1" type="text" style="position:absolute;width:105px;left:351px;top:89px;z-index:0"> ... within your HTML form tags: <form action="paypal.php" method="post"> <input name="formbutton1" type="submit" value="Submit" style="position:absolute;left:372px;top:120px;z-index:2"> </form> ... like the other input ^ is. This will then send the value when you submit the form and will be accessed by $_POST['formtext1']; so if you still have everything setup how we said before (however not including the die() function I showed you) then it should work now with no problems. Adam Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-652984 Share on other sites More sharing options...
mark103 Posted September 29, 2008 Author Share Posted September 29, 2008 thanks, i have exchange the code but it is still the same. Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-653008 Share on other sites More sharing options...
Adam Posted September 29, 2008 Share Posted September 29, 2008 okay try adding to the top of the PHP script: $test = $_POST['formtext1']; die('FORM VALUE IS: ' .$test); is there any value yet? Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-653021 Share on other sites More sharing options...
mark103 Posted September 29, 2008 Author Share Posted September 29, 2008 Thanks but you got this incorrect. I said that I need the script to send the input value on paypal site by the amount value where to require for the payment. Please reconsider my thread once again. It is getting annoying to say same things all over again when you mislead me in the wrong situations. Thanks, Mark Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-653032 Share on other sites More sharing options...
Adam Posted September 29, 2008 Share Posted September 29, 2008 Tell me if I get this wrong... The user fills out the form you showed me before .. the information is then passed on to the script .. which then sends it to paypal. The amount that should be appearing on paypal, is the amount entered in the form? If that's right, then I'm not giving you bad advice as the input named: "formtext1" which is accessed in the PHP script using $_POST['formtext1'] .... is not included in the form. Therefore the amount they enter, is not being sent to the PHP script, and not sent to paypal .. as it's not included in the form! I think you have misread what I've been trying to say... Adam Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-653184 Share on other sites More sharing options...
mark103 Posted September 29, 2008 Author Share Posted September 29, 2008 That's correct. That's what I am trying to do so why it haven't send the information to paypal and changes the amount when I entered the value on my form?? We have tried it all afternoon and have no luck to successful yet. Do you know how to send the information to paypal site and changes the amount when I entered the value on my form?? Hopefully we can get it tonight. Thanks, Mark Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-653193 Share on other sites More sharing options...
mark103 Posted September 30, 2008 Author Share Posted September 30, 2008 please can someone help me please????? Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-653785 Share on other sites More sharing options...
mark103 Posted October 1, 2008 Author Share Posted October 1, 2008 guys??????? anyone??????????? Quote Link to comment https://forums.phpfreaks.com/topic/126261-no-value-number-display-when-go-next-page/#findComment-654825 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.