Jump to content

Recommended Posts

I have been working on this website for a client. One of the features this client requires is the ability to pay for services via PayPal. They have created a Buy Now button and submitted to me the code from said button. The client would also like for some additional information not needed by PayPal to be emailed to them. Currently my form code looks like this:

<form action="service.php" method="post" name="register" onSubmit="document.location='thankyou.htm';">
          <?php
		    $fName    = $_POST['fName'];
		    $lName    = $_POST['lName'];
		    $email    = $_POST['email'];
		    $cEmail   = $_POST['cEmail'];
		    $phone    = $_POST['tele'];
		    $pickUp   = $_POST['pickUp'];
		    $dropOff  = $_POST['dropOff'];
		    $date     = $_POST['date'];
		    $service  = $_POST['service'];
		    $instruct = $_POST['instruct'];
		    $human    = $_POST['human'];
		    $thankyou = 'thankyou.htm';
		    
		    $from = 'From: Joyful Xpressions'; 
		    $to = 'feliciaharried@yahoo.com'; 
		    $subject = 'Service Request';
		    
		    $body = "From: $fName $lName\n E-Mail: $email\n Phone: $phone\n \n Pick Up Location: $pickUp\n Drop Off Location: $dropOff\n Pick Up Date: $date\n \n Service Requested: $service\n \n Special Instructions: $instruct";
		?>
               <h2>Register</h2>
               <p>Give us a try! Use this form to sign up for your first FREE pick up. Enter your information below and submit. 
                    You will get a Paypal button which allows you to select the service you want and proceed to Paypal's 
                    secure payment page to process your payment. You may be asked to enter some information again.</p>
               <hr/>
               <fieldset>
                    <legend>Personal Information</legend>
                    <label for="fName">First Name: </label>
                    <input autocomplete="on" autofocus name="fName" placeholder="First Name" required type="text" />
                    <br/>
                    <label for="lName">Last Name: </label>
                    <input autocomplete="on" name="lName" placeholder="Last Name" required type="text" />
                    <br/>
                    <label for="email">Email: </label>
                    <input autocomplete="on" name="email" placeholder="john.doe@example.com" required type="email" />
                    <br/>
                    <label for="cEmail">Confirm Email: </label>
                    <input autocomplete="off" name="cEmail" placeholder="john.doe@example.com" required type="email" />
                    <br/>
                    <label for="tele">Phone: </label>
                    <input autocomplete="on" name="tele" placeholder="555-555-5555" required type="tel" />
               </fieldset>
               <br/>
               <br/>
               <fieldset>
                    <legend>Service Request</legend>
                    <label for="pickUp">Complete Address for Pickup: </label>
                    <textarea cols="20" name="pickUp" placeholder="Please enter your desired pickup location." required rows="3"></textarea>
                    <br/>
                    <label for="dropOff">Complete Address for Delivery: </label>
                    <textarea cols="20" name="dropOff" placeholder="Please enter your desired drop off location." required rows="3"></textarea>
                    <br/>
                    <label for="date">Pickup Date: </label>
                    <input autocomplete="off" min="2013-01-01" name="date" required type="date" />
                    <br/>
                    <label for="service">Chore: </label>
                    <select name="service">
                         <option value="1 Bag">1 Bag $35.00 USD</option>
                         <option value="2 Bags">2 Bags $65.00 USD</option>
                         <option value="Express Service">Express Service $15.00 USD</option>
                         <option value="King Comforter">King Comforter $20.00 USD</option>
                         <option value="Queen Comforter">Queen Comforter $15.00 USD</option>
                    </select>
                    <br/>
               </fieldset>
               <br/>
               <br/>
               <fieldset>
                    <legend>Special Intructions</legend>
                    <textarea cols="70" name="instruct" placeholder="Please enter any special instructions you may have regarding your service request here." rows="10"></textarea>
                    <br/>
               </fieldset>
               <br/>
               <br/>
               <fieldset>
                    <label>*What is 2+2? (Anti-spam)</label>
                    <input name="human" placeholder="Type Here">
                    <br/>
                    <br/>
                    <input type="hidden" name="return" value="http://expressyourchores.com/thankyou.htm" />
                    <input id="submit" type="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" />
               </fieldset>
               <br/>
               <? if ($_POST['submit'] && $human == '4') {
	    if (mail ($to, $subject, $body, $from)) { 
	    		echo '<p>Test Failed</p>';
	    } else { 
		   echo '<p>Something went wrong, go back and try again!</p>'; 
	    }
	} else if ($_POST['submit'] && $human != '4') {
	    echo '<p>You answered the anti-spam question incorrectly!</p>';
	} ?>
          </form>

I have tried several different methods of submitting the email the redirecting to a Thank You page which contains the PayPal Buy Now button form. and none of my redirects have worked. I have also scoured the internet looking for ways to complete both tasks through one form and have come up with nothing.  The PayPal button form looks like this:

<form action="https://www.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="VPK6MXG9XGY6L" />
     <table>
          <tr>
               <td><input type="hidden" name="on0" value="Chores" />
                    Chores</td>
          </tr>
          <tr>
               <td><select name="os0">
                         <option value="1 Bag">1 Bag $35.00 USD</option>
                         <option value="2 Bags">2 Bags $65.00 USD</option>
                         <option value="Express Service">Express Service $15.00 USD</option>
                         <option value="King Comforter">King Comforter $20.00 USD</option>
                         <option value="Queen Comforter">Queen Comforter $15.00 USD</option>
                    </select></td>
          </tr>
     </table>
     <input type="hidden" name="currency_code" value="USD" />
     <input type="image" src="https://www.paypalobjects.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.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1" />
</form>

Is there any way to combine the two and accomplish both tasks through one form? If not, how could I rewrite the first form's code to redirect to the Thank You page that has the PayPal button? This project has done nothing but make me more and more frustrated. Please note that the variables and email format php code in the first form was moved into the form to place on here. Originally, that code was placed before the doctype of the page. I hope that someone can actually assist me in making this form work as it's the only thing preventing me from turning the project over to the client.

Link to comment
https://forums.phpfreaks.com/topic/279867-dual-action-form/
Share on other sites

Have you tried the "custom" variable for PayPal? How about using the "return" variable (passing the data through GET variables in the URL)?
https://www.paypal.com/cgi-bin/webscr?cmd=p/pdn/howto_checkout-outside

 

Perhaps your answer can be found with a Google search like:

https://www.google.com/search?q=passing+variables+through+paypal

 

 

Note that I don't have a lot of experience with PayPal, so these are just guesses.

Link to comment
https://forums.phpfreaks.com/topic/279867-dual-action-form/#findComment-1439517
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.