CodeIgniter Forums
Paypal_lib Success Page Problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter Archived (from EllisLab) (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Paypal_lib Success Page Problem (/thread-11216.html)

Pages: 1 2


Paypal_lib Success Page Problem - El Forum - 08-30-2008

[eluser]Jesse Schutt[/eluser]
This code is in the "Success" view of the Paypal_lib. It is not displaying any information regarding the _POST information. Actually, it isn't displaying anything at all other than the "Success, Your Payment was received..." Any ideas?

Code:
<h2>Success!</h2>

<p>Your payment was received using Paypal.</p>

&lt;?php if($this->input->post()): ?&gt;
<p>Here's its information:</p>
<p><code>
&lt;?php    
    foreach ($this->input->post() as $key => $value)
        echo '<strong>$key</strong>: $value <br/>';
?&gt;
</code></p>

&lt;?php endif; ?&gt;

If I insert the following, I can see results, so I am pretty sure that there is _POST data.

Code:
&lt;?php
if (isset($_POST))
{
   print "<pre>". htmlspecialchars(print_r($_POST, TRUE)) ."</pre>";
}
else
{
   print '$_POST not set!';
}
?&gt;

Jesse


Paypal_lib Success Page Problem - El Forum - 08-30-2008

[eluser]Jesse Schutt[/eluser]
I'm curious as to why print_r works and not $this->input->post()...


Paypal_lib Success Page Problem - El Forum - 08-30-2008

[eluser]missionsix[/eluser]
since this:

$this->input->post()

is a method, its going to check if the key passed has an associated value. Since you are not passing a key, there is not key / value pair to check it against in $_POST, so its going to return false, which is why you can't see anything.


Paypal_lib Success Page Problem - El Forum - 08-30-2008

[eluser]Jesse Schutt[/eluser]
Thanks for the response MissionSix!

As I'm sure you can tell, I am just learning how to get around in all of this.

What would you suggest I do to access the values held in the $_POST array?

Thanks Much!

Jesse


Paypal_lib Success Page Problem - El Forum - 08-30-2008

[eluser]Bramme[/eluser]
If you want to loop through them, I'd simply use the $_POST array, seeing as

$_POST[$key] == $this->input->post($key) == $this->validation->$key


Paypal_lib Success Page Problem - El Forum - 08-30-2008

[eluser]missionsix[/eluser]
loop through the $_POST[$key]'s, but reference the $_post data through $this->input->post($key). This way your input will be cleaned before use (xss filtering, etc)


Paypal_lib Success Page Problem - El Forum - 08-30-2008

[eluser]Jesse Schutt[/eluser]
Thanks for the help. If it's not too much trouble, could you give me a sample of what you mean? I am doing my best to learn all of this.


Paypal_lib Success Page Problem - El Forum - 08-30-2008

[eluser]missionsix[/eluser]
Yeah, sure:

From your example:

Code:
<h2>Success!</h2>

<p>Your payment was received using Paypal.</p>

&lt;? if($_POST): ?&gt;
<p>Here is its information:</p>
<p><code>
&lt;?php    
    foreach ($_POST as $key => $value)
        echo '<strong>'. $key .'</strong>:'. $this->input->post($key) .' <br/>';
?&gt;
</code></p>
&lt;?php endif; ?&gt;


you were also having problems with your echo statement. You used single quotes with enclosed Vars and that won't work in php.


Paypal_lib Success Page Problem - El Forum - 08-30-2008

[eluser]Jesse Schutt[/eluser]
Thank you very much! I'll go through this and see if I can't figure it out for myself.

I really appreciate your help.

Jesse


Paypal_lib Success Page Problem - El Forum - 08-31-2008

[eluser]Bramme[/eluser]
[quote author="missionsix" date="1220155851"]loop through the $_POST[$key]'s, but reference the $_post data through $this->input->post($key). This way your input will be cleaned before use (xss filtering, etc)[/quote]$_POST is laundered as well... So it really doesn't matter which one you use: $_POST[$key], $this->validation->$key or $this->input->post($key), they're all the same.