• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

PHP email string problem

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    #11
    Originally posted by mudskipper View Post
    From: http://www.worldpay.com/support/kb/bg/pdf/rhtml.pdf



    Is this the mechanism you're using? Looks like you need + for space as doodab suggested. (I always thought URLEncode stuck in %20?)
    I just checked with:

    PHP Code:
    <?php
    $foo 
    = array("foo""bar bar");
    $bar 1;
    echo 
    urlencode("blah $foo[$bar]\n");
    ?>
    and got the output:

    Code:
    blah+bar+bar%0A

    Comment


      #12
      Looks like different languages do different things...

      http - URL encoding the space character: + or %20? - Stack Overflow

      Comment


        #13
        Originally posted by mudskipper View Post
        Looks like different languages do different things...

        http - URL encoding the space character: + or %20? - Stack Overflow
        Either way, PHP's urlencode() uses + for space, which is almost certainly what WorldPay wants

        Comment


          #14
          Cheers again. urlencode does ensure sending of the full text but this is a plain text email, so now the customer gets:

          1+Plant+Guides+Pack+%26pound%3B11.50+each%2C+total ++%26pound%3B11.50+%0D% etc

          The way a WP callback normally works is pretty simple, you post a value to Worldpay eg:

          <form name="order" action="https://secure.worldpay.com/wcc/purchase" method=post>
          <input type="text" name="name">
          etc

          and then process their callback exactly as if it had been submitted directly from your form eg:

          <?php
          $name = $_POST['name']

          I had no problems at all creating variables with my jscript cart but having trouble doing what appears to be exactly the same darn thing in PHP!

          Anyway, its Friday, off to the village club. Ta very much all. You are dismissed for now, will rehire you (for unpaid work experience) on Monday.
          bloggoth

          If everything isn't black and white, I say, 'Why the hell not?'
          John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

          Comment


            #15
            In the callback, try

            PHP Code:
            $description urldecode($_POST['description']); 
            (or whatever). Although it seems a bit odd that they send back the URL encoded version, presumably double-encoded if PHP's automatic processing is decoding it to the encoded version

            Comment


              #16
              Hey! urlencode the sent string, urldecode the received string works! Any sane person would imagine the string would end up as it was!

              Anyway cheers Nick (again). Definitely going for a drink now.
              bloggoth

              If everything isn't black and white, I say, 'Why the hell not?'
              John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

              Comment


                #17
                Originally posted by xoggoth View Post
                Hey! urlencode the sent string, urldecode the received string works! Any sane person would imagine the string would end up as it was!

                Anyway cheers Nick (again). Definitely going for a drink now.

                Comment

                Working...
                X