www.webdeveloper.com
Results 1 to 2 of 2

Thread: Email Then Redirect To PayPal

  1. #1
    Join Date
    Jul 2013
    Location
    Mississippi
    Posts
    1

    Angry Email Then Redirect To PayPal

    I'm trying to do one of two things (whichever I get to work first): Create a form that both submits the data by email AND redirects user to a different page, OR modify a PayPal Buy Now button to request the additional data and have it emailed to the client. The code below is one of many attempts at creating an email form that redirects to another page containing the PayPal button. Can someone please give me some pointers?


    This is before the doctype tag:


    Code:
    <?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";
    ?>

    This is the form:


    Code:
    <form action="service.php https://www.paypal.com/cgi-bin/webscr" method="post" name="register" target="_top" onSubmit="document.location='thankyou.htm';">
                   <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>

    How can I modify this form to redirect to the PayPal button page?

  2. #2
    Join Date
    Mar 2011
    Posts
    1,136
    A <form>'s 'action' attribute can contain only one valid URL. To make a <form> perform more than one task, you must add an onsubmit() function and let JavaScript handle the additional tasks. It would certainly be possible to use JavaScript to execute a formmail script using AJAX before sending the user data to PayPal, but it would be much simpler and more reliable to use PayPal's ipnCallback system. It could be pointed to a script on your site and would include the transaction data so you could do whatever you needed with it, including sending an Email.
    Rick Trethewey
    Rainbo Design

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles