Page 1 of 1
My doubt is how to read array elements recived via $_REQUEST
Posted: Sat Feb 14, 2009 10:55 am
by ullasvk
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.
Re: My doubt is how to read array elements recived via $_REQUEST
Posted: Sat Feb 14, 2009 11:58 am
by NOmeR1
$_REQUEST can contain array if you sent it
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>
Second page (second.php)
Code: Select all
<?php
if(isset($_REQUEST['array'])) {
foreach($_REQUEST['array'] as $element) {
echo $element.'<br>';
}
}
?>