|
-
Apr 18th, 2006, 04:23 AM
#1
Thread Starter
New Member
php form submitting
New to php, so please bear with me.
I created a php page, which reads four values from an array
[$symbols = array('531524','531683','503031','522229');]
After this each of the numbers are read and processed.
I dont like the fact that the values are hard-coded. I wanted to create a form with four textboxes, and on submitting the form the values of the four textboxes should be fed into the array, and processing of the page should continue as usual.
Could anyone tell me how to go about doing this?
thank you
-
Apr 18th, 2006, 04:53 AM
#2
<?="Moderator"?>
Re: php form submitting
PHP has build in support for accessing arrays sent though form data. You just need to set the name of the form item as an array item, ie with [] on the end.
So....
Code:
<form method="post">
<input type="text" name="myArray[]"/>
<input type="text" name="myArray[]"/>
<input type="text" name="myArray[]"/>
<input type="text" name="myArray[]"/>
<input type="submit"/>
</form>
PHP Code:
print_r($_POST['myArray']);
-
Apr 18th, 2006, 06:26 AM
#3
Thread Starter
New Member
Re: php form submitting
didnt think it would be that simple 
thanks.
if im submitting the form to the same page, do i need to use $_POST['myArray'], or is myArray enough?
a followup question:
i have four textboxes in the form. once i submit the form (submit to self) i wanted to display the results in a new column in the same table. right now once i submit, the output page, shows the four textboxes, the submit button below that and the output below the submit button.
is it possible to display the output alongside the respective textbox and the submit button below that (incase the input changes)?
-
Apr 18th, 2006, 03:06 PM
#4
Frenzied Member
Re: php form submitting
Whether its self post or not, you need to use $_POST[] to get posted data.
For your follow up question, get the submitted values in variables, those variables should by default contain empty string, and then print those variables in the columns.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|