i have a form where user can add rows using javascript. i have another page which takes value from the above said form.My doubt is how to read array elements recived via $_REQUEST..
PLEASE ANY ONE HELP ME.
My doubt is how to read array elements recived via $_REQUEST
Moderator: General Moderators
Re: My doubt is how to read array elements recived via $_REQUEST
$_REQUEST can contain array if you sent it
For example:
First page (generating and sending fields)
Second page (second.php)
For example:
First page (generating and sending fields)
Code: Select all
<script>
function addfield() {
document.getElementById('fields').innerHTML += '<input type="text" name="array[]"><br>';
}
</script>
<form method="POST" action="second.php">
<div id="fields">
<input type="text" name="array[]"><br>
</div>
<input type="button" value="Add field" onclick="addfield()"><br>
<input type="submit" value="Submit">
</form>Code: Select all
<?php
if(isset($_REQUEST['array'])) {
foreach($_REQUEST['array'] as $element) {
echo $element.'<br>';
}
}
?>