D
D
doriulbool2016-01-22 16:47:59
PHP
doriulbool, 2016-01-22 16:47:59

Why is the value not being passed via POST?

I welcome all
There is a form:

<form action="/mailer.php" method="post">
<input type="text" name="name" placeholder="Введите имя"><br/>
<input type="text" name="phone" placeholder="Введите телефон"><br/>
<input type="hidden" name="target">
<input type="hidden" name="form_info">
<input id="2check2" name="2check2" type="hidden" value="" />
<button type="submit" onclick="document.getElementById('2check2').value = 'posr';">Отправить!</button>
</form>

Beginning of php code:
session_start();

if ($_POST['2check2'] != 'posr')
die('<strong>Ошибка</strong>: Защита от спама.');

if (isset($_POST['phone']) || isset($_POST['email'])){

$signing = '';

if($_SESSION['utm_source']) {
$signing .= 'utm_source: '.$_SESSION['utm_source'].'<br>';
}
......

There are 3 such forms on the site. From the first, data is sent, from the second, die is executed, as a result of which the script is not executed further. Forms are the same everywhere. If you remove the first check - of course everything works everywhere. I can't figure out what's wrong...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey, 2016-01-22
@doriulbool

Do three forms on the same page have the same field ID?
this can lead to unexpected results when querying DOM elements by id...
id must be unique...

S
Silm, 2016-01-22
@Silm

Dump $_POST at the beginning of the php file, you will see what is the difference in your data, you will understand where to dig.

K
Kirill, 2016-01-22
@quant78

put different id and that's it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question