开发者

PHP Form with PayPal

Looking for a bit of direction to build a PHP form that will be split into 2 parts and ends with a user purchasing a product using PayPal.

The first stage asks a series of questions such as name, address, email etc. It will also ask a simple question with a series of radio buttons, if they choose none then the user will be told that someone will be in touch and end there, if they choose one of the other options then they will be taken to stage two.

Regardless of the options chosen at this point all info from stage 1 will be sent via email.

The second stage basically gets the users PayPal info.

thanks

UPDATE:

I've simplified this considerably, so now there is just one form which will grab the data and send it to an email, and then depending on there choice of radio button either show the message or send them to PayPal.

I need help with checking the radio option and showing the message/redirecting to PayPal, and sending the info to an email address. And also sending the info to PayPal.

The code is as follows:

<?php if(isset($_POST['submit']))

    {

        $to = "info@solidcamxpress.co.uk";
        $subject = "SolidCAM Xpress";

        $name_field = $_POST['name'];
        $email_field = $_POST['email'];
        $phone_field = $_POST['message'];
        $company_field = $_POST['company'];
        $reseller_field = $_POST['reseller'];

        $body = "From: $name_field\n E-Mail: $email_field\n Phone:\n $phone_field\n Company:\n $company_field\n Reseller:\n $reseller_field";

        mail($to, $subject, $body);

    }

    else {

    ?>

    <form method="POST" action="">

        <fieldset>
            <legend>Purchase SolidCAM Xpress</legend>

            <ul>
                <li><label for="name">Name <input type="text" name="name" /></label></li>
                <li><label for="email">Email <input type="text" name="email" /></label></li>
                <li><label for="phone">Phone <input type="text" name="phone" /></label></li>
                <li><label for="company">Company <input type="text" name="company" /></label></li>
            </ul>

            <p>Do you currently have SolidWorks, if yes who is your reseller?</p>
            <ul>
                <li><label for=""><input type="radio" name="reseller" value="None" /> Don't have SolidWorks</label></li>
                <li><label for=""><input type="radio" name="reseller" value="Cad Connect" /> Cad Connect</label></li>
                <li><label for=""><input type="radio" name="reseller" value="Cadtek" /> Cadtek</label></li>
                <li><label for=""><input type="radio" name="reseller" value="CCSL" /> CCSL</label></li>
                <li><label for=""><input type="radio" name="reseller" value="Innova" /> Innova</label></li>
                <li><label for=""><input type="radio" name="reseller" value="NT CAD/CAM" /> NT CAD/CAM</label></li>
                <li><label for=""><input type="radio" name="reseller" value="Solid Engineer" /> Solid Engineer</label></li>
                <li><label for=""><input type="radio" name="reseller" value="Solid Solutions Ireland" /> Solid Solutions Ireland</label></li>
                <li><label for=""><input type="radio" name="reseller" value="Solid Solutions Management" /> Solid Solutions Management</label></li>
                <li><label for=""><input type="radio" name="reseller" value="TMS Scotland" /> TMS Scotland</label></li>
            </ul>

            <p><input type="submit" name="continue" value="Continue" /></p>

        </fieldset>

    </form>

    <?php

    }

    // Whe开发者_运维百科n user clicks continue send all data to info@solidcamxpress.co.uk

    // Then check if user has selected None from the last question then show the following and prevent them from proceeding

    if() {

    ?>

    <p>SolidCAM Xpress requires a valid copy of SolidWorks, we will be in touch shortly to discuss pricing!</p>

    <?php

    } else {

        // User has selected something other than None, send them off to PayPal

    }

    ?>


To store the information, I would use / look into sessions. This allows you to store the data for each step.

Your other method is to add the items back to the page as hidden form elements. My preference would be the session route, however.

How do you plan on sending the data to Paypal? Through a cURL request, or by having them push a button on step 3?

If it is a curl request, the session route is definitely the way to go. If you plan on just having the form in step 3 take them to paypal, the hidden input route might be a better choice.


You'll need to use a session to store the info between page loads: http://www.php.net/manual/en/intro.session.php

Or you could use tabs to keep everything in one page: http://jqueryui.com/demos/tabs/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜