简体   繁体   中英

Convert .NET to php. Response.Redirect

OK so my goal is to get this page:

http://www.orchidfilmcompany.co.uk/Payment.aspx

to work in my php wordpress page.

I dont really know where to start, my whole site is ready to go except for this new pay online page.

The guy who created the .NET page has provided me with the Response.Redirect code which has the merchant peoples url with instID etc. The user will be redirected to this url to complet the payment

I have been looking around online and I found the the equivelant code in php for this is:

Header("Location: $url");

My problem is I dont know what to do with that?

Thats all I need is input box where the user can enter the amount they want to pay, they press submit and it redirects them to the url that I have in the Response.Redirect code. Uses the amount that they entered in the box and they can complete the payment.

If anyone could assist I would really appreciate.

Thanks in advance.

header() function is used to redirect the browser to a specific location.

If you already have the URL where you should redirect the client and you need just to add some amount that came from an input .. you should append that amount in the redirect url

eg:

purchase.html - include this form on your page

<form method="post action="/redirect.php">
    <input type="text" name="amount" value="" />
    <input type="submit" name="sumbit" value="Purchase" />
</form>

redirect.php - put this file next to your html file

<?php
     $amount = (int) $_POST['amount'];
     $urlToRedirect = 'https://secure.wp3.rbsworldpay.com/wcc/purchase?instId=XXX&cartId=OFMaterial&currency=GBP&amount='.$amount;
     header('Location: '.$urlToRedirect);
     exit;
?>

You could try having a form which submits to a PHP page

The PHP page could then pick up the form variables using $_POST['FORM_VAR']

Build a $url variable from the submitted variables + .net page url

Finally use the header("Location: $url"); to take in the built url and redirect.

The form should have an action assigned to it, which is the page that will parse the form. On that page (or within your parsing bit of the code), make sure that the redirect happens there.

The header statement is correct, eg:

<?php
header('Location: http://www.example.com/');
exit;
?>

Would redirect to example.com. So, construct the URL you want to redirect to there. Please note: header directly modifies the headers returned by your webserver and therefore it cannot be called if you already sent other (HTML) output to your browser. Also see the documentation on header here: http://php.net/manual/en/function.header.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM