Hi there I have this problem..
What I want to try is to pass all entries from a form into an array.

for example..
user has to enter several values into a form, like:
name, address ,url, email

on submit the entries have to be inserted in an array called $info .
On the next page these values would be readable by $info[0] , $info[1], etc.

This page should do something like adding to a database, I know there is an easier way to get data into a database, but there has to be a way like this.. more handlings will be done, next to DB-adding also.. Tihs isn't a problem so far..

Hope you'll get what I mean ;-)

Regards,

Trackz

    You can use array naming tecniques in your HTML form, and you will get an array back on the next PHP page.

    <input type="text" name="info[0]"></input>
    <input type="text" name="info[1]"></input>

    The quirks I've run into is that it can only be a single diminsional array, and it has to be an indexed array (using numbers not names).

      really?? should be cool.. going to try it right now.. thanx for this reply.. I'll reply when I have fixed it, or when I'm not able to fix it :-))

      Later,
      Trackz

        If you create a form and submit it to a page, then the variables are created automatically.

        <input type=text name=my_name value="John">

        When that form element is submitted to a PHP page, the variable $my_name is created with the value "John". Not sure if you know that or not. You can then insert $my_name into the database...

        Also, on the submitted page, there is already an array with all of the form values in it. It's called $HTTP_POST_VARS[] or $HTTP_GET_VARS[], depending on if the action of your form was get or post.

        Hope that helps...

        ---John Holmes...

          trackz , the method you are trying to adopt is achievable as you must be knowing by now , but it is not one of the best coding method as when using lots of data and variables , you may loose the track of data, it is always better to know the name of the variable that you are handling rather than just getting it with arrays.

            Yep.. thanx. I was already familiar with the variable thing, but not to have an output from the variables in an array.. Think you didn't really got my explanation, but ok.. That not my strongest point.. Explaining stuff :-)

            Thanx anyway..

            Regards,
            Trackz

              You're right.. Allways is more easy to have them in seperated varabiables, but the script I developed, only handles arrays,

              Another part of it (basically retrieves all data in a record from a DB, and puts in an array)
              Then all sorts of handlings are done..
              ..

              Still have not succeeded in working with the array.. Don't know why , but I will figure it out.. :-)

              See ya.
              Thanx..

              Trackz

                I know your problem use this:
                $HTTP_POST_VARS if you are posting your form or use:
                $HTTP_GET_VARS if you are getting your form.

                This is the array containing all the values in the form even thoese which you usually forget.

                //babak

                  Write a Reply...