Jump to content

Help with HP email code & Paypal amount


Leea

Recommended Posts

I inherited a web site. I admit I don't know PHP and don't have time to learn it before the new program goes live. We have a registration page that after you complete your Paypal it will email the Leader and Registrar the name and address etc. That part works fine. I want to add the dollar amount paid. I am hoping someone nice will just tell me what to add to the code. We have a form page that collects name, address, etc. and passes it to PHP for Paypal processing. Is there something I can add to the string that will either tell me the amount paid or which option the registrant uses? We don't know if there will be one or two guests. The PHP looks like this:

$aContents = array("Name: ",$_POST["name"],"\n"," Email: ",$_POST["eMail"], "\n"," Street: ",$_POST["street_name"],"\n"," City: ", $_POST["city"],"\n",
    " State: ", $_POST["state"],"\n", " Zip Code: ",$_POST["zip"], "\n"," Phone#: ",$_POST["phone"],"\n","\n");

$stringForEmail=implode($aContents);
mail("me@gmail.com", "Registration", $stringForEmail, $additional_headers = null, $additional_parameters = null);

 

and the Paypal (code provided by Paypal) I am testing with follows that:

 

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="JUxxxxxxxxxxxx">
<table>
<tr><td><input type="hidden" name="on0" value="reg test">reg test</td></tr><tr><td><select name="os0">
    <option value="Member">Member $79.79 USD</option>
    <option value="2 - Members">2 - Members $158.79 USD</option>
    <option value="Member & Non-member guest">Member & Non-member guest $168.79 USD</option>
</select> </td></tr>
</table>
<input type="hidden" name="currency_code" value="USD">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

 

Thanks much

Lee

 

Link to comment
Share on other sites

In the standard page HTML there is a form that collects name, address, etc. After you enter the data you click submit and that goes to the PHP. This is the HTML on that page:

 

<form name="registrationForm"  method="post" onsubmit="return validation()" action="RegProcs.php" >

 

The HTML I had in my original post above is in the PHP above the rest of the code so both snipits above are in the same PHP. As I said I don't know PHP do I have no idea how it works. I could include all of the PHP if that helps, I didn't think it was needed. I assume when the PHP runs it sends the email and goes to Paypal.

 

Lee

 

Link to comment
Share on other sites

If you have both forms on the same page, how is it able to submit both at the same time? Because normally it's one form that goes to one page. Can't tell the browser "submit this, then go back and submit the other".

Could it be AJAX? What's the Javascript on that page? In fact, if you would, what's the entire source of the page?

Link to comment
Share on other sites

Hmm, I hadn't thought about that. I think that is my answer, I can't ask for two things at once. I don't know AJAX so there isn't any of that. There isn't any Javascript either. Since you asked here is the whole PHP

 

<html>
    <head>
        <meta charset="utf-8" />
        <title>Process Form and Choose Payment as of 10/18/18</title>
        <style type="text/css">

            table {
                text-align: center;
            }
            #container    {
                padding: 2em;
                width: 500px;
                text-align: center;            
            }
            #left {
            padding: 2em;
            top: 0px;
            float: left;
            }
            #right {
                padding: 2em;
                position: relative;
                top: 0px;            
            }
        </style>
    </head>
 <body>

<?php

$aContents = array("Name: ",$_POST["name"],"\n"," Email: ",$_POST["eMail"], "\n"," Street: ",$_POST["street_name"],"\n"," City: ", $_POST["city"],"\n",
    " State: ", $_POST["state"],"\n", " Zip Code: ",$_POST["zip"], "\n"," Phone#: ",$_POST["phone"],"\n","\n");

$stringForEmail=implode($aContents);
mail("me@gmail.com", "Registration", $stringForEmail, $additional_headers = null, $additional_parameters = null);
 $registration = fopen("registrations.txt","a") or die("Unable to open file");
 foreach ($aContents as $field) {
     fwrite($registration, $field);
 }
 fclose($registration);
 
 echo "Thanks. Looking forward to seeing you there."
?>

<body>
    <div id="container">

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="JUxxxxxx">
<table>
<tr><td><input type="hidden" name="on0" value="reg test">reg test</td></tr><tr><td><select name="os0">
    <option value="Member">Member $79.79 USD</option>
    <option value="2 - Members">2 - Members $158.79 USD</option>
    <option value="Member & Non-member guest">Member & Non-member guest $168.79 USD</option>
</select> </td></tr>
</table>
<input type="hidden" name="currency_code" value="USD">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</div>

 

 

Link to comment
Share on other sites

Okay, I think I was confused.

For a simple answer, move the membership selection to the first form so your PHP code knows what they wanted, then put that value - just that one - into the PayPal form.

<input type="hidden" name="os0" value="(the value the user choose)">

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.