Link to home
Start Free TrialLog in
Avatar of Michael Sterling
Michael SterlingFlag for United States of America

asked on

Why does this paypal form / button / link send me back to my page?

I'm trying to ad a simple "View Cart" paypal form / button to a very simple web page. when testing, if i click on the link, the page that i'm on simply refreshes and doen't go anywhere. what am i doin wrong? (see code below)

i removed the code between the: -----BEGIN PKCS7----- and  -----END PKCS7-----

pieces in the of the value property of the 2nd input control. didn't know if it was sensitive or not...

<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr"  method="post">
    <input type="hidden" name="cmd" value="_s-xclick"/>
    <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----
-----END PKCS7-----"/>
    <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_viewcart_LG.gif"
        border="0"  name="submit" alt="PayPal - The safer, easier way to pay online!"/>
    <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1"
        height="1"/>
    </form>

Open in new window

Avatar of sjklein42
sjklein42
Flag of United States of America image

Try getting rid of the target="paypal".
<form action="https://www.paypal.com/cgi-bin/webscr"  method="post">

Open in new window

Avatar of Michael Sterling

ASKER

man i wish that would've worked. it's still sending me right back to the same page.
i could just put a hyperlink or <a></a> tag around the image i guess...but will that cause any other problems? I've never worked with paypal like this so i'm not sure. my biggest question is when this link does work, is it supposed to open to a specific paypal item, using the information that i removed to pre populate some fields? I realize this may be a question for paypal so i'll direct the latter portion to them, but i don't understand why this button won't open up to a place in pay pal instead of just refreshing the window.
When I get rid of the target="paypal", it seems to work for me.  I click on the button and after a few seconds my page is refreshed with a Paypal page.

Try it here:

http://www.sjklein.com/foo.html

Does it work for you?

I'm using IE8 if that matters.
i'm using firefox...let me try IE...
no go in IE,..same results...
Strange.  Works for me :)

Have you tried firebug addin for firefox to try tracing the network calls?  That might help with debugging.  If you aren't already using firebug you will love it.

But seriously, the page does work for me.  With the link I posted, when I click on the button I  end up on a Paypal page.
i am running firebug. i'm not sure how to trace the network calls in it though...
figured it out, just by chance though. but maybe you can help me out. i placed it on a page that had it within content place holders from a master page initially. so it seemed to just be reposting to the page itself. when i placed in on a simple page with just the button then in went to the paypal site. see code below. how do i make it work within a child page of a master page?
-------THIS WORKS FINE------------

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!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 runat="server">
    <title></title>
</head>
<body>
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_s-xclick"/>
    <input type="hidden" name="encrypted" 
value="-----BEGIN PKCS7-----   -----END PKCS7-----"/>
    <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_viewcart_LG.gif"
        border="0"  name="submit" alt="PayPal - The safer, easier way to pay online!"/>
    <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1"
        height="1"/>
    </form>
</body>
</html>


---------THIS,...NOT SO MUCH (NOT AT ALL)--------

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        Welcome to ASP.NET!
    </h2>
    
    <p>
        To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">
            www.asp.net</a>.
    </p>
    <p>
        You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409"
            title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
    </p>
    <div>
        <img src="image/ecwcPostCard1.jpg" alt="The Post Card" style="width: 900px" />
        <%--<asp:HyperLink ID="hlTest" runat="server" Text="Paypal" Target="_blank" NavigateUrl="https://www.paypal.com/cgi-bin/webscr" />--%>
    </div>
    <%--<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="https://www.paypal.com/cgi-bin/webscr">--%>
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_s-xclick"/>
    <input type="hidden" name="encrypted" 
value="-----BEGIN PKCS7----- -----END PKCS7-----"/>
    <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_viewcart_LG.gif"
        border="0"  name="submit" alt="PayPal - The safer, easier way to pay online!"/>
    <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1"
        height="1"/>
    </form>
    <%--</asp:HyperLink>--%>
    
</asp:Content>

Open in new window

Start Firefox

Tools/Firebug->Open Firebug
I adjust the size of the lower pane to be about half the height of the whole window.

Then click on the Firebug Net tab.  Be sure it is Enabled
On the row below "Net", be sure "All" is selected.

Then do your thing in the main browser window (http://www.sjklein.com/foo.html, for example)

As long as the Net panel is active you should see a trace of all page requests.
ASKER CERTIFIED SOLUTION
Avatar of sjklein42
sjklein42
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks for your help