soundsticks
soundsticks

Reputation: 11

Get submit button value in PHP

I would like to test my button can get the current value from the date's textbox? I got the value of submit button but I couldn't find any code get name of the button. So what should I call I'm able to view the value?

$form_button_layout = '<button class="btn" name="oprf" value="view-log" type="submit">View</button>';

 <form class="well form-inline" method="post"<?= $form_action_override; ?>>

Upvotes: 0

Views: 39828

Answers (5)

Yoko Ishioka
Yoko Ishioka

Reputation: 161

You can do:

if ($_POST['oprf'] == '' || $_POST['oprf'] == NULL) {
//this checks to see if there has been a value that was sent with the
//form
}

I usually use isset for cookies.

Upvotes: 0

Mohamed Abdallah
Mohamed Abdallah

Reputation: 154

Add type property with submit type="submit" to button tag this will submit the form then receive the form inputs value in php script with super global variable $_POST['input name'] or $_GET[] wdepends on from action property value by default GET.

Upvotes: 0

LovinItAll
LovinItAll

Reputation: 133

If you'd like to get the value of 'oprf' above, then:

$value = $_POST['obrf'];

Should do it in php.

Upvotes: 4

Roger
Roger

Reputation: 1693

You can try this one

if(isset($_POST['oprf'])) {
 echo $_POST['oprf'];
}

Hope this helps

Upvotes: 0

Rijk
Rijk

Reputation: 11301

I don't think this works consitently in all browsers. Better to work with a customized name attribute.

Upvotes: 0

Related Questions