Submitting Multiple Form Fields In An Array / Loop

Jul 17, 2005

I have the following form

<FORM NAME="form1" METHOD="POST">
<?php do { ?>
<input name="approve[]" type="checkbox" id="approve[]" value="<?php echo
$row_rs['ID']; ?>">
<select name="select">
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>

<?php } while ($row_rs = mysql_fetch_assoc($rs)); ?>
</FORM>

I want to acheive a loop that inserts a record into a database that enters
the id and the value they have selected (if the approve input box was
ticked)

so far I have this:
<?
foreach($approve as $aID) {
$insertSQL = "INSERT INTO TABLE('refID','optionSelected') VALUES
('$aID','')";

}

?>

How do I enter the select value within this loop?
I assumed that it would be just
$insertSQL = "INSERT INTO TABLE('refID','optionSelected') VALUES
('$aID','$select')";

ADVERTISEMENT

Submitting Form Multiple Times In .each() Loop - Only Last Submit Sending

Jun 16, 2011

I am trying to submit a form then update some values and submit it again. However, when I do this only the LAST version is being submitted. I get one error for Unsafe Javascript attempt to access frame with URL domain2.com from frame with URL domain1 . Domains, Protocols and Ports must match.

form code:

<form id="hiddenform" method="post" enctype="multipart/form-data" action="http://www.actonsoftware.com/acton/forms/userSubmit.jsp" accept-charset="UTF-8" target="tintest">

the target is a hidden iframe with the id="tintest"

This is my code:

var tbody = $("#vmMainPage table:first tbody");
var lng = tbody[0].rows.length - 1;
var mnstr = "items: ";
$("#vmMainPage table:first tbody tr").each(function(i){

[Code]....

View 1 Replies View Related

Get Fields Value Without Submitting Form?

Feb 28, 2009

Is there in PHP something similar to javascript's getElementById('').... I'd like to get the value of an input field without submitting a form...

View 1 Replies View Related

Submitting Only A Particulate Field When There Are Many Fields In A Form

Dec 16, 2010

I have a webpage in php which contains many fiields.But when i enter data into one particular field(say the first field),i need the form to get submitted and do certain task.

View 5 Replies View Related

Validate Form Before Submitting (more Complicated Than Checking For Empty Fields)

Jul 8, 2010

i have a form containing inputs for times (specifically, an opening and closing time). when the submit button is pressed, it goes to a php page where these inputs are added to a database. i want to check a few things before allowing the form to submit. for example, i want to make sure that the start time is earlier than (less than) the end time. here's the form:

Opens:
<select name="starthour1">
<option value="00">12</option>
<option value="01">1</option>
<option value="02">2</option>

[Code]....

however, checking this stuff after submitting doesn't make sense. i suppose i could redirect back to the initial page if the error was found, but that doesn't seem efficient.

also, i was thinking maybe i could have some php on the page with the form that checks for validity. if it validates, it then posts to the php page that inserts stuff into the database. does this make sense and is it possible?

is there a better solution? i imagine there is something i could do with javascript but i haven't been able to figure it out.

additionally i'd like to inform the user of invalid inputs with text that appears next to the input box. i should be able to figure this out once the rest is working though.

View 4 Replies View Related

Submitting Multiple Rows With One Form.

Sep 9, 2004

I am trying to create a form for my users to submit multiple rows to a databse, I have a few questions.

1. I would like the form to have an option before they start filling out the form, the option should be how many kinds of pop they would like to submit with options 1-5.

2. I would like the information that they submit to be submitted to the database but, I would like it to be in different rows. eg 5 kinds of pop 5 rows.

View 1 Replies View Related

Submitting (Editing) Multiple Rows In A Form

Jun 15, 2006

i am having a problem related to form submission(not a simple form submission)
b4 reading plz open this URL to have an idea of what i am talking about Code:

View 1 Replies View Related

Multiple Of Values In Third Textbox Without Submitting Form?

Jul 2, 2009

want to made a form in which there is three fields.1.product value suppose 1500.2.number of product:2.3.then want to show multiple of these values in third textbox without submitting form.

View 3 Replies View Related

Form Submitting Multiple Files Not Retaining Data?

Aug 2, 2010

Ok so i have a html form, 10 files get uploaded. 6 images and 4 pdf. some of theses files are required others not.

My problem is when my script verifys the data and retuns to the user that he/she has errors all the file inputs are come back as blank... and if the user re-submitts... the files are not saved.

This form has other fields other than the files as well.

I tried putting $_POST in the value of my inputs but that does not repopulate with the local file names.

I would like it so my users dont need to re enter all the files they want to upload if they made 1 or a few mistakes.

edited:
SO is this normal that the post isnt giving me the file name? is the file still saved as temp on the server?

View 3 Replies View Related

Html - Prevent Multiple Inserts When Submitting A Form?

Jan 25, 2010

Sometimes the user may press Enter twice, and the post is inserted twice.

Is there a solution to prevent this other than check if there is already a post with the same title and content?

View 12 Replies View Related

Submitting Multiple Select Form Values To Salesforce?

Jun 18, 2009

I have a contact form on my site that has 1 multiple select field. Since I'm using this form to also store the values to a DB I'm also sending the data to Salesforce CRM through CURL.It's something like this:HTML Code:

<label for="interested_in"> Interested in Service <span class="req">*</span></label>
<select id="interested_in" class="selectfield" multiple="multiple" name="interested_in" title="Service Interest">

[code]...

View 5 Replies View Related

Submitting Multiple Rows To Database With One Form In Codeigniter

Sep 29, 2010

I'm trying to create a bulk edit page for an app that I'm working on. The table contains rows of products each of which have three editable fields.

<tr>
<input type="hidden" name="id" value="10">
<td>SKU<td>
<td>Product Name</td>
<td>
<select name="product_category" value="" tabindex="4">
<option value="1">Category 1</option>
[Code]..

Every row can be edited and there is one submit button on the page. How should I format this correctly so that I can update each entry in the database with the values?

View 1 Replies View Related

Loop Through Multiple Text Fields Labeled 'number'?

Oct 16, 2010

Loop through form input text fields.Loop through multiple text fields labeled 'number' and it's only submitting the very last number field instead of all 'number' fields.

Code:for ($i = 0; $i < count($_POST['number']); $i++) {
$sql='INSERT INTO orders (custNum,contractNum,equipId,prodNum)
VALUES ('
. "'" . mysql_real_escape_string($_SESSION['custNum']) . "', "

[code]...

View 1 Replies View Related

Submitting Multiple Form Data Inputs On Single Submit Button?

Jun 15, 2011

Here's the code that I'm working on

<div class="Normal_P">
<span class="Normal_C">
<form action="<?php getLink("http://www.atouchofmoore.net/certificate_stage3.php" array(
<?php

[Code]....

Now, I have it so that the user can choose to have up to 5 certificates, and I need a submit button that will send each certificate with only the selected option from the select input.

View 3 Replies View Related

Loop Form Fields In Counter?

Jun 14, 2010

I have 1 form and in that form I loop through my database of people and display form fields such as first name, last name, age, nationality etc and each form field is displayed as such:

PHP Code:


// while loop here for each db record
<input type="text" name=firstname[$personid] />
<input type="text" name=lastnamename[$personid] />
<select name=nationality[$personid]></select>
// close while loop

[Code].....

View 2 Replies View Related

Loop Form Validation With Non Required Fields

May 13, 2009

Basically I am looking to validate a form with non-required fields. If the fields are required and dont pass validation, I want it to list those fields. If the fields aren't required, just to skip the field and go to the next. Here is what I have so far, and I'm just looking for generalization, not actual code. Form submitted via post post variables are cleaned and assigned to associative array via foreach and varaible variables:

[code]...

Now, I want to loop through ad_info and validate the fields that are required. Some fields aren't required. How would I skip those for validation? Do I split the array somehow and then merge it after validation? Do I put the non-required fields in an array and 'continue' past them in a loop? I'm trying to make this as dynamic as I can. My eventual goal is to put the values in the array into the database.

View 4 Replies View Related

Dynamic Form Fields/multiple Page Form?

Apr 7, 2002

It is for a friends out of print booksite, where visitors can request multiple books to be searched by adding one at a time to a cart (javascript), then once all added they submit to another form where they enter their personal details and all is sent through. The problem is at the moment they cannot change whats in the cart without refreshing the browser window and losing everything.

1) present for asking how many books they want to search for
2) display multiple rows of the same input fields depending on how many books they say they want to have searched for?i.e

title|author|publisher|etc
title|author|publisher|etc
title|author|publisher|etc

3) when these are submitted they could see these above the next part of the form where they enter their details with the option to go back and delete/amend.
4) send all the info to my colleague.

if so has anyone seen a similar script that I could take a look @ to see if I can hack it to suit my needs?

View 2 Replies View Related

Multiple Form Fields

Aug 3, 2005

I have multiple textfields. Code:

<input type="text" name="date1" id="date1" value="" />
<input type="text" name="date2" id="date2" value="" />

I want to insert each field into one database table column(date).

View 9 Replies View Related

Sticky Form With Multiple Fields

Jul 17, 2005

how do i create a sticky form with multiple fields? say
i want a form with:

name: [input field name]
address: [input field address]
country: [input field country]

[submit button]

and if a user presses the submit button it will show
exactly the same page with the fields that the user
has entered filled in with the values (s)he entered
(validation of the values will come later), and the
info of the form sent.

should i name all the values in the form separately
or should i use an array?

View 2 Replies View Related

HTML Form Multiple Fields?

Dec 11, 2010

I have html form that looks like:

<form method="post" action="?a=up">
...some mysql query...
while ($i = mysql_fetch_array($result)) {
<input name="name[]" type="text" value="<?=$i['name'];?>" />
<input name="years[]" type="text" value="<?=abs($age);?>"/>
<input name="to[]" type="checkbox" value="<?=$i['id'];?>" />

[code]....

View 3 Replies View Related

Processing Multiple Form Fields?

Jan 22, 2011

Is there a better way to process a form where I need to save a link and link text against a language and company? The example below works, but I think it is hard work. I have added the language and company id to the key of the link and link text fields as a way of grouping them together and passing the other information through to PHP and into the DB.

$newlinks = array();
foreach($_POST as $post_key => $post_value) {
if (substr($post_key, 0, 7) == 'newlink') {
$posted_link = explode('_', $post_key);

[code]....

And the HTML

<input type="text" name="newlink_1_1" value="" />
<input type="text" name="newlinkname_1_1" value="" />

There can be multiple languages and companies displayed on one page.

View 1 Replies View Related

Changing Multiple Fields Within One Form?

Jun 29, 2010

I tried searching for an alternate thread about my dilemma, but couldn't fine one so I'm posting a new one.

I have a user editing page contained by one form, where values are fetched from an SQL table. Imagine it like this:

HTML Code:
<form name="userlist" action="" method="post">
<table>
<tr>
<td>username</td><td>level</td></td>active</td>

[Code]....

So in essence I would need to find out which users have had their properties changed and then run a single SQL query to update all. Is this possible, and if, how ? Or do I need to run a query for each user separately?

View 1 Replies View Related

Form, Posting Multiple Fields

Apr 23, 2007

I have a product list page, users can check the product then go to an e-mail form, that lists the products they checked.

On this, they can then chose a quantity for every product, how do I make it so when they send the e-mail, it gets the quantity for each product (using PHP mail, to send)?

The field would be:
<input type="text" size="4" maxlength="4" value="1" name="quantity">

But that wouldn't work for multiple ones? Would I use a "foreach" statement, somehow?

View 14 Replies View Related

Select Multiple Form Fields To SQL?

Jan 15, 2011

i would like to submit the following code to my database as a mutiple selection box. when i submit i just get the last selected value for example if i hold ctrl and press 1  2  3  4   i am only receiving 4 on my database.

Code: [Select]Hours Of Availability:<br>
<select name="availability" multiple="multiple" size="9">
<option value="Monday - Period 1">Monday - Period 1</option>
<option value="Monday - Period 2">Monday - Period 2</option>

[code]...

View 13 Replies View Related

Comparing Form Fields With Data Base Fields And Highlighting The Form Fields?

Nov 9, 2009

the following two scenarios (PHP+MYSQL)

Scenario1: I need to compare the HTML Form field values with the Database field values and highlight the form fields in some color whose values are different from database values before submitting the form (to alert the user).

Scenario2: On loading the form, i need to compare the values present in 2 different database tables (tables are having different column names but the information is same). the fields which are not same needs to be highlighted in the html form to indicate the users that the master data is varying from secondary data.

View 2 Replies View Related

Mail Function & Multiple Form Fields

Jul 17, 2005

I'm having some problems with a php mail form where I am wanting to
send information from 10 form fields in a e-mail. the way I have it
structured for the mail command is

mail ($to,$subject,$message);

where message is made up from the multiple fields from the form e.g

$message = "Name: ".$strName."
";
"Company: ".$strCompany."
";

The e-mail is sent fine but it only gives me the persons name and not
the extra fields.

Can anyone point me in the right direction?

View 4 Replies View Related

Using Post When Multiple Form Fields Share Same Name And Id?

Nov 19, 2010

That title probably doesn't mean much but what I have is a form that is generated dynamically. I hooks into a table of products, pulls out there name. I then create a form that displays the product with a checkbox and textbox next to it.

<form id="twitter-feed" name="twitter-feed" action="<?php echo $this->getUrl('tweet/') ?>index/tweet" method="post">
<table><tr>
<?php

[code]....

As you can see there are checkboxes and textfields for each record. When I examine the $_POST data from the form it only retains fields for the last record.

View 5 Replies View Related

HTML - Form Handling Multiple Fields?

Oct 30, 2010

What would be the best way to intercept multiple fields via PHP? Currently I have a login.php file which is pretty simple:

<form method="POST" action="auth.php">
Code:<br />
<input type="text" name="code" />
<input type="submit" id="submit" value="Submit" />

[code]....

Then in the auth.php I get the value via the POST:

$value = $_POST['code'];

The problem with this is that I would have a quite amount of fields, and every field would have a submit button assigned. Then I would need a if condition for every field name available, which I don't want to.

View 3 Replies View Related

Passing Multiple Fields From Query In A Form?

Mar 9, 2009

I am writing a module to add users to my system. Getting the details from the query is fine but I'm having all sorts of issues passing the fields in the form. This is the code:

PHP Code:

$search=$_REQUEST['search'];
$username=$_REQUEST['username'];
mysql_connect("00.0.0.00",xxxx,xxxx);
@mysql_select_db(DBDESC) or die( "Unable to select database");

[code]....

I need only the fields that I have selected to be passed when the submit button is clicked. I tried using a drop down menu with the query result as the options and I have tried using radio buttons and the wrong data is being passed.

View 4 Replies View Related

Combine Multiple Fields To One Value For Form Submission?

Jun 23, 2010

Continuing from my earlier question, how can I combine the month, day, and year <select>s into a single "date" value, so that it arrives at my PHP script as

$_POST['date'], in MySQL format YYYY-MM-DD?

View 8 Replies View Related

PHP Mailto Form Multiple Fields MySQL

Apr 26, 2007

I'm trying to edit a email form that is about 30+ fields. Right now the form only inserts the data to a MySQL DB. What I would like to add is an email (mailto) feature that sends the entered data from the form to an email address  as well as add it to the DB at the same time. I'm not a beginner in PHP MySQL but not quite a novice just yet.

View 4 Replies View Related

Creating Sticky Forms For Multiple Form Fields?

Aug 25, 2010

I am attempting to create a program for a local auction house. I arrived at a stand still on a certain issue which is creating a sticky form. On the "enter auction details page" the user will be entering data as the auction is in session.

1. item Description
2. Item Price
3. Bidders Id
4. Qty

Of course it would be repetitive to require the user to keep entering the same data for every bidder, so I want to stick the obvious fields which are "item description" & "Item Price" as these don't change until a new item comes up for sale. As of know I am processing the input on a separate page which records all input to the database with a redirect back to the  "enter auction details page". I have tried many times to get the item description and item price fields to stick. These would need to change as the user moves onto the next item in which the description and price would change as well.

Here is my current code for this part:

Code: [Select]<?php
session_start(); 
$field_itemDescription = ""; //iyem description, default as blank

[code]....

View 1 Replies View Related

Sorting A Multidimentional Array By Multiple Fields

Dec 30, 2001

If the multidimentional array was a mysql TABLE, what i'm trying to do would look like this:

SELECT * from array WHERE 1 ORDER BY field1 ASC, field2 DESC, field3 ASC
and so on.

I already constructed a function do to so, but this function, or should i say these 2 functions, sort only the first field properly, and then any other field is sorted improperly. PHP Code:

View 5 Replies View Related

Post Form Fields Into Array - 'group' Each Form Field

Apr 14, 2010

A user can choose a number between 1 and 10 from a list box. Based on the value of their choice I display the same form 1 - 10 times on the page and this form is there to collect personal data. Each form will have a small number of text fields and also some checkboxes e.g:

name (text)
dob (text)
option 1 (checkbox)
option 2 (checkbox)
option 3 (checkbox)

(note the checkboxes should be grouped as an array as they are dynamically built) My question is, how do I 'group' each form field so that when the page is posted (saved) I can capture the correct data for each form filled in? I know arrays are involved somewhere here but not sure how it is implemented.

View 4 Replies View Related

Array To Be Numbered From 1 To How Ever Many Fields That Are Needed In The Form - Mysql And Array?

Nov 17, 2010

I need the array to be numbered from 1 to how ever many fields that are needed in the form and have a mysql field name and the title of the field also in the array.

[Code]....

View 1 Replies View Related

Codeigniter Form Validation Callback Checking Multiple Fields

Aug 20, 2010

I have this controller set up for a login:

<?php
class Login extends Controller {
function __construct() {
parent::Controller();
$this->form_validation->set_error_delimiters('', '');
$this->output->enable_profiler(TRUE);
}

[Code].....

What I am looking at is the line that does the form validation callback >> $this->form_validation->set_rules(array('username','password'), 'Username', 'callback_terminal_login_check[$username,$password]'); I know this is not right. Basically what I want to do is check the username and password against the Authentication->DoTerminalAuthentication model to process the user's login. I want to pass the $username and $password form fields.

[Code].....

View 3 Replies View Related

Multiple Array Loop

Jul 12, 2007

I'm trying to set up a loop that writes the code for submitting a form, by using the variables from an array. Code:

View 1 Replies View Related

INSERT Multiple Records From FORM In LOOP?

Mar 24, 2009

I have this aproval form where the inserts come from a loop... How do I get all these records into my db table?

Form:

PHP Code:

echo '<form action="insert.php" method="get" name="form1">';
$sql="SELECT * FROM ".$prefix."_users ORDER BY rankpoints DESC"; 
$result = mysql_query($sql);

[code]....

And insert.php:

PHP Code:

$rank = $_POST['rank'];
$points = $_POST['points'];

mysql_query("INSERT INTO ".$prefix."_users (rank,rankpoints) VALUES ('$rank','$points')") 

View 3 Replies View Related

Store Form Fields To An Array

Mar 19, 2006

i have a form which consists of several fields for name, address, number etc. i use a php form to process this and output it onto a html form. the thing is, i'd like to store the information in an array. so for each user, the array will have their details. and this can be printed on the screen. can you tell me how this is possible. i have seen examples of arrays, but the values are assigned to the variables already.

View 1 Replies View Related

Converting Form Fields Into An Array

May 16, 2006

I have a form that enters inventory values based on date. Each day has a certain inventory value. Some days of the month have the same inventory values. I have 31 checkboxes, one for each day of the month and the inventory value form field.

I enter the inventory value and then check the days that the inventory value applies to.

When inserting the data into the mysql database, I would like to loop through the days and if a day is checked, then I run the mysql query to insert the data.

How do I convert all the checkboxes into an array or is there a better way to do it?

View 2 Replies View Related

When Posting A Form The Fields Come Out As An Array?

Feb 14, 2010

i noticed that when posting a form the fields come out as an array.

like if i do

if(isset($_POST['submit'])) {
print_r($_POST);
}

what i usually do for form fields is the following.lets say i have something like this (this is how i usually do it)

<form method="POST" action="">
<label>First Name: </label>
<input type="text" name="fname">[code]....

then i'll have (im excluding field validation to make it look clear)

if(isset($_POST['submit'])) {

$fname = $_POST['fname'];
$lname = $_POST['lname'];
$phone = $_POST['phone'];

mysql_query("insert into table(fname,lname,phone) values('$fname','$lname','$phone')");

header("Location: gosomewhere.php");

}

since the post outputs are in an array format how else can i write this when im dealing with over 100 fields?how are the big guys doing it out there? or how are you doing it?

edit: the most ive dealth with is around 60 fields. im building this cms that takes in alot of data per form to put together information from a customer.

View 5 Replies View Related

Form Validation For Fields In Array

Mar 10, 2007

I've writen the script and it all works now I want to do some validation to make sure the user enters a 'correct value', simple enough you might think, anyway what I have is 40 fields in my form which are sent to 5 different arrays for processing, so:

$q1 = $_POST['q1'];
$q2 = $_POST['q2'];
$q3 = $_POST['q3'];
//.......
//then
$typea = array( '1' => $q1 , '10' => $q10 , '11' => $q11 , ........ '40' => $q40);
//so now I want to validate...
$check = 0;
foreach ($typea as $key => $value)
{
if ($value != 0 || $value != 2 || $value != 3)
$check = 1;
echo $value . " , " . $check . "<br />
";  //to make sure values are what i think
}
if ($check == 1)
   //go back to form
else
   //do the processing

$check always returns as 1 though, even when the values are 0 , 2 or 3

View 5 Replies View Related

Adding Multiple Items To An Array In A Foreach Loop?

Mar 22, 2011

Sample Code

<?php
$items = array(
array(
'forename' => 'Foo',
'surname' => 'Bar'

[Code]....

The result is perfectly acceptable and the code is readable. My question is: is there a better / more efficient / prettier way to do this?

View 3 Replies View Related

Loop Through The Result Set Array And Output It As Xml (multiple Rows)?

Feb 7, 2011

Iam using Zend RestController to output student data (from database) in xml format. Iam assigning the row data from controller, to the view elements (column by column).

Like this:

$this->view->name = $name;
$this->view->desc = $desc;

But, what if have to show data of multiple rows? I have the following code in my index.xml.phtml, which gives only 1 row data:

<pre>
<?php
$doc = new DOMDocument();

[code]....

How can i loop through the result set array and output it as xml (multiple rows)?

View 1 Replies View Related

Put Together Array To Use With Foreach Loop By Getting Columns From Multiple Tables?

Sep 16, 2009

What I am trying to do is put together an array to use with a foreach loop by getting columns from multiple tables. Here is my query:

$results = mysql_query("SELECT column1,column2,column3 FROM table1,table2,table3,table4");

I think I need an associative array but am not quite sure how to put it together. The data would be in columns as it would be in the table just merged. Is this possible to do?

View 8 Replies View Related

ADVERTISEMENT