BardsWork
BardsWork

Reputation: 566

How to read POST data in PHP from button

I have a button that depicts delivery or pickup. The code is as follow:

$output .= "<button type='submit' name='checkout' value='checkout|delivery''>Delivery</button>\n";
$output .= "<button type='submit' name='checkout' value='checkout|pickup'>Pick Up</button>\n";

When I go to the Inspector in Google Chrome, I can see that in Network --> Headers there is a Post with the data that I need.

How can I retrieve the checkout:checkout|delivery via PHP?

Upvotes: 0

Views: 86

Answers (1)

Richard
Richard

Reputation: 2815

You can retrieve it with this:

$_POST['checkout']

And in an if-statement:

if($_POST['checkout'] == "checkout|delivery"){
    // Should be delivered
} else {
    // Will be picked up
}

Upvotes: 3

Related Questions