array in HTTP_POST in php form

See how can we use array in http_post in php form

Lets the html form is like this

[html]<form action="" method="post">

<input type="text" name="profile[fname]" placeholder="First Name">

<input type="text" name="profile[surname]" placeholder="Surname">


Here the data will be posted as array with name `profile`

You can validate and get it like this:

[php] if(isset($_POST[‘profile]’)) { $fname = $_POST[‘profile’][‘fname’];

$lname = $_POST[‘profile’][‘lname’];

echo ‘Submitted First Name : ‘.$fname;

echo ‘<br>Submitted Last Name: ‘.$lname;


Spread the love