dongyongan9941 2016-11-06 19:02
浏览 21

如何在表单操作之前运行php

I have a form that runs a php file that stores data to a wp database however after it runs the php file I need to top function as a paypal button. The code is this at the moment:

<form id="candle-form" action="<?php bloginfo('template_directory');?>/db-submit.php" method="post">

  ....form body (works properly)

</form>

basically I need to run action="https://www.paypal.com/cgi-bin/webscr" after the php function so that the user can checkout with paypal. Is there any way to do this? I tried redirecting with Location: at the end of the php file but then the paypal link just goes to paypal.com and doesn't retain the form's info

  • 写回答

1条回答 默认 最新

  • duandi8613 2016-11-07 05:55
    关注

    For your form submission, submit to an external file.

    You can run any operations before this code is set. Make sure there isn't anything modifying the headers. This code is verified to be working.

    {
    // Prepare GET data
    $query = array();
    $query['cmd'] = '_xclick';
    
    $query['business'] = ''; //Your email or account ID
    $query['lc'] = 'US'; //Location
    $query['item_name'] = ''; //Item Name
    $query['button_subtype'] = 'services'; //Button type
    $query['no_shipping'] = '0'; //Shipping?
    $query['bn'] = 'PP-BuyNowBF:btn_buynow_LG.gif:NonHosted'; //Button type
    $query['amount'] = ''; //amount
    $query['return'] = ''; //Return url after purchase
    $query['cancel_url'] = ''; //If user cancels payment, url to take them to
    
    // Prepare query string
    $query_string = http_build_query($query);
    
    header('Location: https://www.sandbox.paypal.com/us/cgi-bin/webscr?' . $query_string);
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题