www.webdeveloper.com
Results 1 to 8 of 8

Thread: registration form submit to db then redirect to paypal

Hybrid View

  1. #1
    Join Date
    Oct 2013
    Posts
    16

    registration form submit to db then redirect to paypal

    Hello looking for a way to submit registration form data to db then redirect to Paypal to pay. I am creating a paid membership website with a monthly subscription. have the form created works fine, with out the payment button. it redirects to register?success.php which tells customers to check email. How ever with a Paypal subscription button add to page it either goes to success.php if i remove the Paypal link, but if i leave it in the form action spot it redirects to Paypal with out updating db. Any suggestions would help.

    Hers a look at the register.php page.

    <?php
    if (isset ($_GET['success']) && empty($_GET['success']))
    {
    echo 'Thank you for registering,<br> to complete your registration please follow the link in your email.';
    }
    else
    {

    if (empty ($_POST) === false && empty ($errors) === true)
    {
    $register_data = array(
    'username' => $_POST['username'],
    'password' => $_POST['password'],
    'user_firstname' => $_POST['user_firstname'],
    'user_lastname' => $_POST['user_lastname'],
    'user_email' => $_POST['user_email'],
    'email_code' => md5($_POST['username'] + microtime())
    );



    register_user($register_data);
    header ('Location: https://www.paypal.com/cgi-bin/webscr ');
    exit();
    }
    else if (empty($errors ) === false)
    {
    echo output_errors($errors);
    }

    ?>
    <form name="_xclick" action="" method="post">
    <ul>
    <li>
    Username*<br>
    <input type="text" name="username">
    </li>
    <li>
    Password*<br>
    <input type="password" name="password">
    </li>
    <li>
    Password Confirmation* <br>
    <input type="password" name="password_confirmation">
    </li>
    <li>
    First Name*<br>
    <input type="text" name="user_firstname">
    </li>
    <li>
    Last Name*<br>
    <input type="text" name="user_lastname">
    </li>
    <li>
    Email*<br>
    <input type="text" name="user_email">
    </li>
    <li>

    </li>



    <input type="hidden" name="cmd" value="_xclick-subscriptions">
    <input type="hidden" name="item_name" value="RegFee">
    <input type="hidden" name="business" value="myemail">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="no_shipping" value="1">
    <input type="image" src="http://www.paypal.com/en_US/i/btn/btn_subscribe_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
    <input type="hidden" name="a3" value="10.00">
    <input type="hidden" name="p3" value="1">
    <input type="hidden" name="t3" value="M">
    <input type="hidden" name="src" value="1">
    <input type="hidden" name="sra" value="1">


    </ul>
    </form>

  2. #2
    Join Date
    May 2014
    Posts
    2
    Just a suggestion, but I wouldn't be using md5 to encrypt your password especially on a paid site. This method is a little outdated.

  3. #3
    Join Date
    Oct 2013
    Posts
    16
    Thank you but i am not going to be using md5 for the time being it makes it easy to for testing. How ever i do not think that me using an outdated encryption for password at this time is relavent to the question at hand, which is how to post form data to db then redirect to paypal? What i have done trying to fix problem is

    1) left my header to redirect to register?success.php. Where form action is https://www.paypal.com/cgi-bin/webscr. This takes me to paypal cart to sign in or use other means of credit card. however it does not update form data to db.

    2) replaced register?success.php with https://www.paypal.com/cgi-bin/webscr. This updates db but does not take me to the paypal cart to finish payment instead takes me to https://www.paypal.com main website.

    any recommendation would be grateful

  4. #4
    Join Date
    Dec 2002
    Location
    Seattle, WA
    Posts
    1,843
    I am not all that familiar with paypal's transactions/processing. I do know that they offer an API for accessing transaction information and processing. I suggest that you thoroughly go thru their documentation.

    If I remember right the API uses Oauth. I would not suggest using Oauth unless you can find a very good script to run Oauth from and/or have a very firm understanding of how Oauth works.

    NOTE: SHA-160 has been available in PHP since 4.3.0 (via sha1()). and for what ever reason you need it in versions before that you can use
    PHP Code:
    <?php
    if(!function_exists('rotl'))
    {
        function 
    shr($x$n)
        {
            return (
    0x80000000 $x) ? (($x >> 1) & ~0x80000000 0x40000000) >> $n-$x >> $n;
        }
        function 
    rotl($x$n)
        {
            return (
    $x << $n) | shr($x32-$n);
        }
    }
    function 
    sha160($str$raw_output false)
    {
        
    $h0 0x67452301;
        
    $h1 0xefcdaB89;
        
    $h2 0x98badcfe;
        
    $h3 0x10325476;
        
    $h4 0xc3d2e1f0;
        
    $m "$str\x80"str_repeat("\x0", (64 - (($l strlen($str)) + 1) % 64) + 4). pack('N'$l << 3);

        while(
    $t substr($m064))
        {
            
    $a $h0;
            
    $b $h1;
            
    $c $h2;
            
    $d $h3;
            
    $e $h4;
            
    $w array_values(unpack('N16'$t));

            for(
    $j 0$j <= 79; ++$j)
            {
                if(
    16 <= $j)
                {
                    
    $w[] = rotl($w[$j-3] ^ $w[$j-8] ^ $w[$j-14] ^ $w[$j-16], 1);
                }
                if(
    $j <= 19)
                {
                    
    $k 0x5a827999;
                    
    $f = ($b $c) ^ (~$b $d);
                }
                else if(
    $j <= 39)
                {
                    
    $k 0x6ed9eba1;
                    
    $f $b $c $d;
                }
                else if(
    $j <= 59)
                {
                    
    $k 0x8f1bbcdc;
                    
    $f = ($b $c) ^ ($b $d) ^ ($c $d);
                }
                else if(
    $j <= 79)
                {
                    
    $k 0xca62c1d6;
                    
    $f $b $c $d;
                }
                
    $t rotl($a5) + $f $e $k $w[$j];
                
    $e $d;
                
    $d $c;
                
    $c rotl($b30);
                
    $b $a;
                
    $a = (int) $t;
            }
            
    $h0 $a $h0;
            
    $h1 $b $h1;
            
    $h2 $c $h2;
            
    $h3 $d $h3;
            
    $h4 $e $h4;
            
    $m substr($m64);
        }
        
    $hash pack('N*'$h0$h1$h2$h3$h4);
        return (
    $raw_output) ? $hash bin2hex($hash);
    }
    function 
    sha160_file($filename$raw_output false)
    {
        if(
    file_exists($filename) && is_file($filename) && is_readable($filename))
        {
            return 
    sha160(file_get_contents($filename), $raw_output);
        }
        return 
    false;
    }
    ?>

  5. #5
    Join Date
    Oct 2013
    Posts
    16
    so what i am looking for is this

    1) new members fill out basic registration form (username, password, email, first name, and last name.)

    2) upon clicking on the submit button (paypals subcription button); members info in form is inserted to database. (this works with out paypal with a regular submit button.)

    3) after submit and insert to database, member is redirected to paypal for payment.

    i have tried the header (location, as well as changing the action in the form I know that this is possible because I have come a cross other sites that ask new members for basic registration info and that are redirected to paypal for payment.

    one expample of such site would be https://teamtreehouse.com/subscribe/...an=2&trial=yes this site charges new members a 25 dollar fee a month for membership. the have it set up to either pay by credit card or be redirected to Paypal

    i would like to only be redirected to paypal after all form data is s

  6. #6
    Join Date
    Apr 2007
    Location
    Ho Chi Minh
    Posts
    1
    if you need to letter time more second

    header("refresh:300;url=http://www.paypal.com");

  7. #7
    Join Date
    Oct 2013
    Posts
    16
    All this is doing is redirecting me back to my register.php page. with no form. Its updating to database but not redirecting me to paypal

    do i leave form action blank? my header was set to register?success.php i replaced it with above code.

    any documantion for the code so i code read and see what could be problem?

    or is there another way to achieve what i would like?

  8. #8
    Join Date
    Jan 2014
    Posts
    49
    not sure

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