FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


how to handle post data as an array





openaasman
could any one help me to catch array data in post method.
i have tried every possible way through php but i am not getting all the value in the array. i am only getting last value of array passed in post data.
Rhysige
if you post the code you are using we can analyse where it is falling down Smile
jamez
@ Rhysige: he does not need to post the code..

@ openaasman: here is it:

form.htm (sample name only)
Code:

<form method="post" action="form_action.php">
Num1:&nbsp;<input type="text" name="num[]">
Num2:&nbsp;<input type="text" name="num[]">
Num3:&nbsp;<input type="text" name="num[]">
Num4:&nbsp;<input type="text" name="num[]">
Num5:&nbsp;<input type="text" name="num[]">
</form>


or you can use for loop:
Code:

<form method="post" action="form_action.php">
<script language="JavaScript">
var i;
for(i=0;i<5;i++){
document.write("Num"+(i+1)+":&nbsp;<input type='text' name='num[]'>");
}
</script>
</form>



form_action.php
Code:

<?
echo "Values inputs are:&nbsp;&nbsp;";
foreach($_POST['num'] as &$value){
echo $value."&nbsp";
}
?>


This code is mine.. Helps?
ammonkc
how does that work? isn't the actual $_POST variable an array? I'm guessing thats why its only giving the last value.
Related topics
script backup database
phpbb cash mod problemos
AJAX tutorial [2nd part now updated]
PERL - post data from one script to another (Without LWP)
small php+mysql script, big reward
Is there any way to submit post data with php?
Automaticly Submit Post Data. 20 fri$ up for grabs.
Posting Data to multiple sites at once?
why is post not allowed on here
Checking if user exists, whats wrong?
pulling data out of a database and putting it on main page
My post gone
Transfer data between pages on different servers?
how to create post views?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.