Ilyes GHOMRANI
Ilyes GHOMRANI

Reputation: 122

Validate inputs with the same name recieved htmlspecialchars() error raised

i have a form with multiple inputs with the same name as the following:

.... OTHER INPUTS BIENG VALIDATED ....
<input type="text" id="firstname_conjoint_associe" placeholder="" class="form-control " value="" name="firstname_conjoint_associe[]">
<input type="text" id="lastname_conjoint_associe" placeholder="" class="form-control " value="" name="lastname_conjoint_associe[]">
<input type="text" id="email_conjoint_associe" placeholder="" class="form-control " value="" name="email_conjoint_associe[]">
<input type="text" id="firstname_conjoint_associe" placeholder="" class="form-control " value="" name="firstname_conjoint_associe[]">
<input type="text" id="latname_conjoint_associe" placeholder="" class="form-control " value="" name="lastname_conjoint_associe[]">
<input type="text" id="email_conjoint_associe" placeholder="" class="form-control " value="" name="email_conjoint_associe[]">
.... OTHER INPUTS BIENG VALIDATED ....

I need to mention that the inputs giving me the error are the listed above and they are not being validated.

the error is as follows:

htmlspecialchars() expects parameter 1 to be string, array given

Upvotes: 0

Views: 53

Answers (1)

Sohrab
Sohrab

Reputation: 131

Inputs that their name contains [] at the end send an array to the server. You may not pass an array to htmlspecialchars(), as it excepts string.

Upvotes: 1

Related Questions