0

How do i get the special characters from a form submit. For example: a form got a name="customer[firstname]".

The url will be customer%5Bfirstname%5D=Test.

i've tried:

$firstName = $_GET['customer[firstname]'];

also the same with urldecode, rawurldecode.

Saty
  • 22,443
  • 7
  • 33
  • 51
Puya Sarmidani
  • 319
  • 2
  • 7

2 Answers2

3

Using [...] in your name attributes you are creating an array that you can access on the server as:

$firstName = $_GET['customer']['firstname'];

And if you omit the value in the brackets, you get a numerical array:

name="customer[]"

Would become on the server:

// for example, you should really loop over `$_GET['customer']` instead...
$firstName = $_GET['customer'][0]; 
jeroen
  • 91,079
  • 21
  • 114
  • 132
-1

This is about HTML entities.

Take a look here: http://php.net/manual/en/function.html-entity-decode.php

Frank B
  • 3,667
  • 1
  • 16
  • 22