Noob seeking for help with incremental name's in values.

Hello all . . .

I only recently started to self learn PHP , and this small project i am making is quite a challange for me.
The scripts below are not realy writen by me , but i wished to tie them together to get a fully working code.

What is suppose to happen is :

In the form i wish to put a special button that puts extra input fields in the form.

After the form is submited ,with whatever amount of feilds in it, goes to a processing.php file that sorts all the info gathered and finaly sends all this data formated in to the last file that will be inluded in the index.php.

i already have the code for increcing the amount of inputs but the problem is , all imputs have the same names. Coz of that i get a mess.

What i need is to each input to have a unique name or id , that way the processing file would receive different names(id’s) with different values(what ever is writen in the inputs by users).

for example:

I have 2 enitial fields displayed on form.html , i click the button “add new” and add 5 more input fields.
All this data must be processed by a process.php and on the output write all of this information formated in the last file in a row that will be displayed in the index by useing [php]<?include("blablabla.php");?>[/php]

The input increment is done by a java script. the problem is sending data with unique id(name) and receiving it.

The form file :

[php]

<?include("header.php");?> <?$i = 1; ?> #newlink {width:600px}
Product:   Price: %
 <p>
    <br>
     <input type="submit" name="submit1">
    <input type="reset" name="reset1">
</p>

     <p id="addnew"></p>
 <FORM>
</form>
Product: value="<?$_GET[$i];?>">  Price: value="<?$_GET[$i].$curency;?>"> 
<?include("footer.php");?>

[/i][/php]

The processing file :

[php]<?
$timestamp = strftime("%d-%m-%Y %H:%M:%S %Y"); // for later use (ignore it)
$i =1;
####################################################################################

if(($_POST[‘prodname’]!="")&&($_POST[‘price’]!="")){

####### dont edit the code after this line! ###################################
$writetocsv = $_POST['prodname1'] . "," . $_POST['price1']"%" <BR> . $_POST[$i] . $_POST[$i];
         $fp = fopen("data/data.csv", "a");
         fwrite ($fp,$writetocsv);
         fclose ($fp);
                        echo "<script>alert('Data sent.')</script>";

}
else{
echo “”;
}
echo “”;
?>[/php]

Perhaps someone knows a easyer way , since i am not sure how to make stuff due to the lack of knowlage in php. I also tryed arrays but , as said before , too tough when you are a noob :frowning:

Please help.

Sponsor our Newsletter | Privacy Policy | Terms of Service