views:

219

answers:

8

Hi,

I'm currently integrating a payment system into my website. I have a response script which basically takes in the data from the secure server and displays to the customer if the payment has gone through or not. My problem is that the if statement is actually displaying both messages to the customer, even if the payment has been successful or unsuccessful.

Here is the If statement:

<?
if ($result == "00") && ($payersetup == "00") && ($pmtsetup =="00"){
?>  
Thank you
<br/><br/>
To return to the home page <a href="http://www.xx.com"&gt;&lt;b&gt;&lt;u&gt;click here</u></b></a>
<br/><br/>

<?
} else {
?>

<br/><br/>
There was an error processing your subscription.  
To try again please <a href="http://www.xx.com/signUp.html"&gt;&lt;b&gt;&lt;u&gt;click here</u></b></a><br><BR>
Please contact our customer care department at <a href="mailto:[email protected]"><b><u>[email protected]</u></b></a>

<?
}
?>

I have also tried doing this the following way, however with this method, the body is blank - no text is displayed.

<?
if ($result == "00") && ($payersetup == "00") && ($pmtsetup =="00"){
$thanks = "Thank you! \n\n To Return to the homepage <a href=http://www.epubdirect.com&gt;Click Here</a>"; 
echo $thanks;
} 
else 
{
$nothanks = "There was an error processing your subscription.\n\n To try again please <a href=http://www.epubdirect.com/signUp.html&gt;click here</a>. \n\n If the problem persists, please contact our customer care department at <a href=mailto:[email protected]>[email protected]</a>";
echo $nothanks;
}
?>

And after that I tried to put the HTML into a seperate document and use require_once() but this didn't work either - same result as previous - blank body.

Any one have any ideas?

EDIT:

I have tried some of the ways suggested however I'm still having the blank page problem :(

Here is the way I have gone ->

<?
if (($result == "00") && ($payersetup == "00") && ($pmtsetup =="00"))
{
require_once('thankyou.html');
} 
else 
{
require_once('error.html');
}
?>

This still gives me a blank page even though the syntax looks right?

+9  A: 

Try:

if (($result == "00") && ($payersetup == "00") && ($pmtsetup =="00") ) {
   ...
   ...
}
luckytaxi
Yes, I think the missing parentheses are the problem.
Skilldrick
thats a no-brainer :D
Hannes
+2  A: 

You probably mean:

if ($result == "00" && $payersetup == "00" && $pmtsetup == "00") {

The if ends after the closing ).

deceze
+3  A: 

I wonder how your condition is run at all because you have ( and ) missing in your if conditions:

if (($result == "00") && ($payersetup == "00") && ($pmtsetup =="00")){...}

Or simply:

if ($result == "00" && $payersetup == "00" && $pmtsetup =="00"){...}
Sarfraz
+2  A: 

Simple clean way

<? if (($result == "00") && ($payersetup == "00") && ($pmtsetup =="00")):?>
 Thank you
 <br/><br/>
 To return to the home page <a href="http://www.xx.com"&gt;&lt;b&gt;&lt;u&gt;click here</u></b></a>
 <br/><br/>
<?php else : ?>
 <br/><br/>
 There was an error processing your subscription.  
 To try again please <a href="http://www.xx.com/signUp.html"&gt;&lt;b&gt;&lt;u&gt;click      here</u></b></a><br><BR>
 Please contact our customer care department at <a  href="mailto:[email protected]"><b><u>[email protected]</u></b></a>
<?php endif ?>
JapanPro
WOW, who has voted down, whats wrong with this?
JapanPro
I'd voted it down (hastily, which I undid) because it's a bad answer. All you did was rewrite the original code in your own style with no justification of why it's better and no explanation of what was wrong in the first place. How is anybody supposed to learn from this?
meagar
thanks for highliting , Problem is with if as every one knows out of it. if you see all answers in this post , you will find i am using if(): which gives a clean way to embed in html. this is alternative of all other answer.
JapanPro
+8  A: 

To add to others answers:

Your original code:

if ($result == "00") && ($payersetup == "00") && ($pmtsetup =="00")

is a syntax error. Once the PHP parser sees ) which marks the end of the if conditional it expects to see another statement(s) or a { to mark the beginning of if body. But when it sees && it throws this syntax error:

PHP Parse error:  syntax error, unexpected T_BOOLEAN_AND

I think you've disabled your error reporting thats why you are seeing a blank page.

codaddict
Moral of the story: Turn on all error reporting during development.
Andrew
@Andrew - how to I turn on error reporting? I am working on a server I did not set up.
TaraWalsh
@TaraWalsh You can set error reporting in the script using the error_reporting() function: http://php.net/manual/en/function.error-reporting.php
Brendan Bullen
A: 

i think your page is call two times that is why both message is shown just try header location after a statement and then get the response on other page it is not possible that if and else both are working at same time header('Location: specificpage.php'); exit();

Rohit
+2  A: 

As I cant post comments (I dont really get that, but whatever), here is what you have to do to turn error reporting on:

In your PHP-script: Use the function error_reporting, described here

Or, if you have acces to your php.ini, refer to this document.

You should use a local development server (like XAMPP on Windows/Linux) on your own computer and when you are done deploy on the real server.

ThE_-_BliZZarD
A: 
Ryan Chouinard