473,516 Members | 3,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get the form values to an array

2 New Member
here is some code im working on to get the choice selected from the user and put that into an array that can be used for other stuff... my problem is that i cant get anything to save into the array... I urgently need a response as this is for a school project im doing and this is the last module i need to complete...

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>radio</title>
  4. </head>
  5. <body>
  6. <?php
  7.  
  8. for( $x = 0; $x<3; $x++ ){
  9.     if (!isset($_POST['submit'])) { ?>
  10.         <form method="POST">
  11.         <div align="left" width='700'>
  12.         755<input type="radio" name="choice" value="755"> 
  13.         750<input type="radio" name="choice" value="750"> 
  14.         700<input type="radio" name="choice" value="700" checked> 
  15.  
  16.         </form>
  17.     <?
  18.     } else {
  19.  
  20.         $choice_1=$_POST['choice'];
  21.         $choice_array[]=$choice_1;
  22.         echo $x."<br>";
  23.         echo $choice_1."<br>";
  24.         echo $choice_array[$x]."<br>";
  25.  
  26.         }
  27.     }
  28. if (!isset($_POST['submit'])) {?>
  29.         <form method="POST">
  30.         <input type="submit" name="submit" value="Submit">
  31.         </form>
  32.         <?
  33.         }
  34.         ?>
  35. </body>
  36. </html>
if anyone could tell me what im doing wrong id be verry greatfull!
Jul 18 '07 #1
3 2186
code green
1,726 Recognized Expert Top Contributor
You have two forms.
The first with the data and the second with the submit button.
The second form only is submitted with no data.
If you placed error trapping and debugging statements in your code you would not have problems like this
Jul 18 '07 #2
ak1dnar
1,584 Recognized Expert Top Contributor
Thread title changed to remove unwanted contents from the thread title.

Ealier : URGENT help needed! problem with an array from a loop...
Jul 18 '07 #3
nathj
938 Recognized Expert Contributor
here is some code im working on to get the choice selected from the user and put that into an array that can be used for other stuff... my problem is that i cant get anything to save into the array... I urgently need a response as this is for a school project im doing and this is the last module i need to complete...

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>radio</title>
  4. </head>
  5. <body>
  6. <?php
  7.  
  8. for( $x = 0; $x<3; $x++ ){
  9.     if (!isset($_POST['submit'])) { ?>
  10.         <form method="POST">
  11.         <div align="left" width='700'>
  12.         755<input type="radio" name="choice" value="755"> 
  13.         750<input type="radio" name="choice" value="750"> 
  14.         700<input type="radio" name="choice" value="700" checked> 
  15.  
  16.         </form>
  17.     <?
  18.     } else {
  19.  
  20.         $choice_1=$_POST['choice'];
  21.         $choice_array[]=$choice_1;
  22.         echo $x."<br>";
  23.         echo $choice_1."<br>";
  24.         echo $choice_array[$x]."<br>";
  25.  
  26.         }
  27.     }
  28. if (!isset($_POST['submit'])) {?>
  29.         <form method="POST">
  30.         <input type="submit" name="submit" value="Submit">
  31.         </form>
  32.         <?
  33.         }
  34.         ?>
  35. </body>
  36. </html>
if anyone could tell me what im doing wrong id be verry greatfull!
Perhaps you could separate the pages out. So that you have one page with the form definition on, including all the radio buttons and the submit button.

This would have an action pointing to another page that handles the selection.

If this is not possible in this situation then have one IF statement. Check if the form has been submitted, if so handle the request else define the form in one go.

Cheers
nathj
Jul 19 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
5477
by: Yang Li Ke | last post by:
Hi I know that there is a meta tag function to get all meta tags from a url. I am searching for a similar function that would get all values of a form. something like : <form> <input type="text" name="name" size="10"> <input type="text" name="url" size="40"> </form>
0
1556
by: R. Rajesh Jeba Anbiah | last post by:
Many people often ask the question related to form validation. Here is my style. It just gives the idea; but not exactly what I do in development. Comments are welcome. ------------->8---------------------
5
3772
by: Paul C-T | last post by:
Hi, Am I trying to be too clever here? I am trying to write a PHP page to enable me to enter values into a form then write those values to a text file. I want to use the form & table that displays these fileds and values in different ways so am creating one page and parsing variables to it. The problem appears to be in trying to write...
9
29990
by: Ken | last post by:
How can I reset the initial form variables that are set with session statements when clicking on a button? I tried this but the function was not called: <?PHP function reset_form($none) { $_SESSION = array(); } ?> <form enctype="multipart/form-data" name="company_info" method="post" action="add_pic.php">
1
2386
by: kyma via .NET 247 | last post by:
Hi, I haveto use VB to create a form that reads an exisiting XML fileand then allows updates via the VB form. My problem is that I was able to get VB to read a simple XML file(people.XML), but I'm having problems figuring out how to get VBto read a more complex XML file (people2.xml) and then useadditional text boxes on the same form to add...
11
12778
by: Ahmet AKGUN | last post by:
Hi; is it possible to open one form in .net platform that we have its name in string ? I have string sFormName = "frmCustomer"; and I must automatically open Customer form. or is it possible to get one referance of an item on form ?
4
2250
by: Cerebral Believer | last post by:
Hi I need help! Forgive me I am a PHP newbie. I have a small script that enables me to send a form from an HTML page. I want to use the HTML formatted form because the design of my website is complex, and I don't want to have to mess around with formatting a page using HTML within php. So basically the "action" of the HTML page sends the...
2
7036
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply. Each dynamically created...
26
2784
by: Jerim79 | last post by:
I need to create a form that takes a number that the user enters, and duplicates a question the number of times the user entered. For instance, if the customer enters 5 on the first page, when they press next the form generates "How old are you?" 5 times on the page. The customer will answer all 5 questions then press next. Finally, all the...
1
2811
by: Muchach | last post by:
Hello, Ok so what I've got going on is a form that is populated by pulling info from database then using php do{} to create elements in form. I have a text box in each table row for the user to enter input. I need to take this user input and put it back into the database. What would be the best method to do this. I can't use a normal post...
0
7405
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7574
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7547
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5106
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3252
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1620
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.