how to use php to handle input from a cloned form field in php

how do I change my php backend to accomodate the user inout from a cloned input field and display it  as an array.  I already have a code like this below.
              <?php
               $name = $_POST['name'];
and the html field looks like:-
              <input name='name[]' type='text'>
and then there is javascript to clone it but I want to take up all the user input so that I can use this to see all the user input I used:-
              $abc = print_r($name)
24ernestAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
Here is a simple version.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>HTML Input array</title>
</head>
<body>
<h1>HTML Input array</h1>
<?php 
if (isset($_POST['submit']) && $_POST['submit'] == "submit") {
   	foreach($_POST['name'] as $value) {
			echo $value."<br>";
		}
	}
 ?>
<br>
<form method="POST" action="#" onsubmit="return check();">
<input name='name[]' type='text' value="Allen"><br>
<input name='name[]' type='text' value="Bob"><br>
<input name='name[]' type='text' value="Charles"><br>
<input name='name[]' type='text' value="David"><br>
<input type="submit" value="submit" name="submit" >
</form>

</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
How to answer this question yourself (and for future reference, here is what to do when you do not know what a variable contains)...

When a form is submitted from an HTML page to a PHP script, the contents of the request variables are contained in $_REQUEST, which includes several other variables - $_SESSION, $_COOKIE, $_GET, $_POST.  You can use var_dump() to print out the contents of these variables.  When you see the way the request variables are structured, it will be easy to write the programming to use them.  PHP print_r() gives much of the same information.

PHP has several iterators and control structures that allow you to affect program logic flow, based on the contents of variables.  In this case, foreach() might be the best, but beware of external data that is unpredictable in any dimension.  It is the programmer's job to secure the application against attack vectors.
http://php.net/manual/en/security.php
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.