Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get $Post in PHP with Dot in the name

Tags:

php

This should be a very basic question in PHP, but I couldn't get a nice solution in web. Please some experts show me with example.

I am trying to read value of 3 textboxes, those names are input_38.1, input_38.2, input_38.3

so my code is echo $_POST['input_38.1']. But it doesn't print the 1st textbox's value. What is the way to get all three textbox's values.

Thanks in advance.

like image 339
John Supakin Avatar asked Dec 13 '13 20:12

John Supakin


2 Answers

I am trying to read value of 3 textboxes, those names are input_38.1, input_38.2, input_38.3

From the PHP Manual:

Dots and spaces in variable names are converted to underscores. For example <input name="a.b" /> becomes $_REQUEST["a_b"].

So, you'd need to write:

echo $_POST['input_38_1'];

To avoid confusion, it's a good idea not to use dots in your form's name attributes.

like image 117
Amal Murali Avatar answered Sep 30 '22 05:09

Amal Murali


You need to change your echo statement:

$_POST['input_38_1'];

I usually stay away from using dots in my variable names.

like image 45
JTFRage Avatar answered Sep 30 '22 07:09

JTFRage