1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need Help Adding PayPal Button To Page

Discussion in 'PHP' started by AdBuck, Feb 8, 2008.

  1. #1
    Hello Guys,

    I need help adding a PayPal Button to one of my site pages.

    The code I need to add is
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="<? include('paypal.php'); ?>">
    <input type="hidden" name="item_name" value="Premium Membership">
    <input type="hidden" name="amount" value="<?= $rowe["price"] ?>">
    <input type="hidden" name="no_shipping" value="0">
    <input type="hidden" name="no_note" value="1">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="lc" value="MX">
    <input type="hidden" name="bn" value="PP-BuyNowBF">
    <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"></form>
    Code (markup):
    I have to add this code to this part of the file
    <?
    
    if (isset($_POST["name"])) {
    require('config.php');
    
    if( strtolower($_POST['code'])!= strtolower($_SESSION['texto'])){ 
    echo "SECURITY CODE ERROR... "; 
     include('footer.php');
    
    exit();
    }
    
    $name=limpiar($_POST["name"]);
    $email=limpiar($_POST["email"]);
    $topic=limpiar($_POST["topic"]);
    $subject=limpiar($_POST["subject"]);
    $comments=limpiar($_POST["comments"]);
    
    
    if ($name==""){echo "Error"; exit();}
    if ($email==""){echo "Error"; exit();}
    if ($topic==""){echo "Error"; exit();}
    if ($subject==""){echo "Error"; exit();}
    if ($comments==""){echo "Error"; exit();}
    
    $laip = getRealIP();
    
    
    $query = "INSERT INTO tb_contact (name, email, topic, subject, comments, ip) VALUES('$name','$email','$topic','$subject','$comments','$laip')";
    mysql_query($query) or die(mysql_error());
    
    echo "Your message has been sent correctly.";
    
    ?>
    Code (markup):
    Please let me know where I have to add the PayPal Button code in the file script above.

    If you will be able to help me, I will give you 50 free member visits on my site adbuck.net
     
    AdBuck, Feb 8, 2008 IP
  2. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #2
    Are you sure that's where you want it? I would place it after the ?> but I aint sure you have the correct file.
     
    shallowink, Feb 8, 2008 IP
  3. AdBuck

    AdBuck Banned

    Messages:
    142
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes, the PayPal Button needs to be somewhere inside the <? and ?> because if I would put the PayPal Button outside of those <? and ?> the PayPal Button would be displayed before the Submit Form. And the <? and ?> is the code when the form is submitted.

    As you can see in the code above, almost the last line "echo "Your message has been sent correctly.";" that message is showing up after the form is submitted and I need to add a PayPal Button under that message.
     
    AdBuck, Feb 8, 2008 IP
  4. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #4
    You will have to wrap it inside of an echo statement . after the echo "your message has been sent" but it makes zero sense cause the php ends there and you should be able to just put the html code. Is this being included in some other file and that php block is being contained by other HTML elements?
     
    shallowink, Feb 8, 2008 IP
  5. AdBuck

    AdBuck Banned

    Messages:
    142
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I would appreciate if you could wrap that code for me of PayPal Button.

    Thank you very much.
     
    AdBuck, Feb 8, 2008 IP
  6. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #6
    <? include('paypal.php')
    What is this? or what is the variable being pulled from that file ?
     
    shallowink, Feb 8, 2008 IP
  7. AdBuck

    AdBuck Banned

    Messages:
    142
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It's regarding this page "http://adbuck.net/advertise.php".

    Fill out all the fields with some info and then click "Submit". After you have clicked "Submit" you will see a new page saying "Your message has been sent correctly." and I would like to have a PayPal button under that text.
     
    AdBuck, Feb 8, 2008 IP
  8. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #8
    ok, is paypal.php echoing a variable or not?
     
    shallowink, Feb 8, 2008 IP
  9. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #9
    
    
    
    echo "Your message has been sent correctly.";
    
    echo '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">';
    echo '<input type="hidden" name="cmd" value="_xclick">';
    
    echo '<input type="hidden" name="business" value="' ;
    include "paypal.php";
    echo '">';
    echo '<input type="hidden" name="item_name" value="Premium Membership">';
    echo '<input type="hidden" name="amount" value="' . $rowe["price"] . '">';
    echo '<input type="hidden" name="no_shipping" value="0">
    <input type="hidden" name="no_note" value="1">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="lc" value="MX">
    <input type="hidden" name="bn" value="PP-BuyNowBF">';
    echo '<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" border="0"';
    echo 'name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!"></form>';
    
    ?>
    
    
    Code (markup):
    There I just did to match as best I could
     
    shallowink, Feb 8, 2008 IP
  10. AdBuck

    AdBuck Banned

    Messages:
    142
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    There is no paypal.php file.

    But I have removed that line and tried it to see if it will work and nothing. It only showed the text and no button.

    I think I will try to figure out something else, because many people were unable to fix the problem. Even my host and they know a little php.

    But thanks for trying, if you would like I can give you some free clicks on my site if you have a website.
     
    AdBuck, Feb 8, 2008 IP
  11. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #11
    Well something tells me it's something else cause the above works.

    http://www.shallowink.com/ts.php

    Button shows up. So it could be part of the logic proceeding that statement. or the database call.
     
    shallowink, Feb 8, 2008 IP
  12. AdBuck

    AdBuck Banned

    Messages:
    142
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Yes, something is wrong with the source script I have.

    But I will try to figure it out.
     
    AdBuck, Feb 8, 2008 IP
  13. The Critic

    The Critic Peon

    Messages:
    392
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #13

    Just use heredoc syntax:

    
    echo <<<EOPF1
    Your message has been sent correctly.<br />
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="
    EOPF1;
    
    include('paypal.php');
    
    echo <<<EOPF2
    "><input type="hidden" name="item_name" value="Premium Membership">
    <input type="hidden" name="amount" value="{$rowe['price'] }">
    <input type="hidden" name="no_shipping" value="0">
    <input type="hidden" name="no_note" value="1">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="lc" value="MX">
    <input type="hidden" name="bn" value="PP-BuyNowBF">
    <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"></form>
    EOPF2;
    
    PHP:
    It saves you the mess of escaped characters and it's easier to read. If you could get the output from that paypal.php file in a better way you could put it all in one piece.
     
    The Critic, Feb 8, 2008 IP
  14. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #14
    Yeah, heredocs are easier to read. Doesn't matter though his problem is somewhere other than what he presented. Still don't get calling the include file in that location. Call it beforehand and put the var in place cause I know it's just the business email.
     
    shallowink, Feb 8, 2008 IP
  15. AdBuck

    AdBuck Banned

    Messages:
    142
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    There is no include file.

    Just this code needs to be added without any include stuff
     
    AdBuck, Feb 8, 2008 IP
  16. The Critic

    The Critic Peon

    Messages:
    392
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Then what's this?

    
    <input type="hidden" name="business" value="<? include('paypal.php'); ?>">
    
    PHP:
    Agreed.
     
    The Critic, Feb 8, 2008 IP
  17. AdBuck

    AdBuck Banned

    Messages:
    142
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    My mistake, I just noticed the paypal.php file on my server.

    So what I have to change ?
     
    AdBuck, Feb 8, 2008 IP
  18. The Critic

    The Critic Peon

    Messages:
    392
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #18
    That file should spit out something, probably at the end. Find where it echos this output and change it to return.

    
    //From this
    echo "Output";
    
    //To this
    return "Output";
    
    PHP:
    It may be in the form of a variable instead. Either way, make that change and then on your main script put something like this:

    
    $business=include('paypal.php');
    echo <<<EOPF
    Your message has been sent correctly.<br />
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="{$business}">
    <input type="hidden" name="item_name" value="Premium Membership">
    <input type="hidden" name="amount" value="{$rowe['price'] }">
    <input type="hidden" name="no_shipping" value="0">
    <input type="hidden" name="no_note" value="1">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="lc" value="MX">
    <input type="hidden" name="bn" value="PP-BuyNowBF">
    <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"></form>
    EOPF;
    
    PHP:
    That's it. :)
     
    The Critic, Feb 8, 2008 IP
  19. AdBuck

    AdBuck Banned

    Messages:
    142
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    Could you just add for me the PayPal button code to this code:

    *I was trying to add teh code, but it didn't work.
     
    AdBuck, Feb 8, 2008 IP
  20. The Critic

    The Critic Peon

    Messages:
    392
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Well, assuming you modified the include...

    
    <?
    if (isset($_POST["name"])) {
    require('config.php');
    
    if( strtolower($_POST['code'])!= strtolower($_SESSION['texto'])){ 
    echo "SECURITY CODE ERROR... "; 
    include('footer.php');
    
    exit();
    }
    
    $name=limpiar($_POST["name"]);
    $email=limpiar($_POST["email"]);
    $topic=limpiar($_POST["topic"]);
    $subject=limpiar($_POST["subject"]);
    $comments=limpiar($_POST["comments"]);
    
    
    if ($name==""){echo "Error"; exit();}
    if ($email==""){echo "Error"; exit();}
    if ($topic==""){echo "Error"; exit();}
    if ($subject==""){echo "Error"; exit();}
    if ($comments==""){echo "Error"; exit();}
    
    $laip = getRealIP();
    
    
    $query = "INSERT INTO tb_contact (name, email, topic, subject, comments, ip) VALUES('$name','$email','$topic','$subject','$comments','$laip')";
    mysql_query($query) or die(mysql_error());
    
    $business=include('paypal.php');
    echo <<<EOPF
    Your message has been sent correctly.<br />
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="{$business}">
    <input type="hidden" name="item_name" value="Premium Membership">
    <input type="hidden" name="amount" value="{$rowe['price']}">
    <input type="hidden" name="no_shipping" value="0">
    <input type="hidden" name="no_note" value="1">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="lc" value="MX">
    <input type="hidden" name="bn" value="PP-BuyNowBF">
    <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"></form>
    EOPF;
    ?> 
    
    PHP:
     
    The Critic, Feb 8, 2008 IP