www.webdeveloper.com
Results 1 to 12 of 12

Thread: I have a user form with data inside of the form made of of sql and php… the input..

  1. #1
    Join Date
    Jun 2011
    Location
    California
    Posts
    383

    Lightbulb I have a user form with data inside of the form made of of sql and php… the input..

    fields are active and editable. the data that resides in the fields right now are names and addresses and phone numbers...

    the input field for cellphone is CELLPHONE.

    cellnumber is returning a number in the input box, it's labeled as CELLNUMBER..

    How to I pass "CELLNUMBER" in the _GET when they dive into the next page?

    Do i have to create a variable for it... easy question i'm sure.

    THanks in advance.

    Here's my insert:

    PHP Code:
    sql::safe_insert('RE',login::$re_company, 'DME', 'CODE_', $pant->hex);
    Here is my table field:

    <td>Phone Cell </td><td><?php inp('CELLNUMBER',13'phone'); ?></td>
    I'm already passing id in the _GET with this array.. based off an object.

    <?php echo "<td><a href='" matry::base_to('test/trace', array('pant_id' => $pant->id)) . "'><ul class='controls'>
                    <li id='check_orders'><span class='symbols'>L</span><span class='label'>Skip</span></li>
                    </ul></a></td>"
    ;?>

  2. #2
    Join Date
    Nov 2012
    Location
    Jakarta
    Posts
    42
    In order to pass it to the next page, you need to add it to the url that points to the next page.

    Let us say, your current page containing cellnumber is called "myform.php" and you want to pass it to "myaction.php".

    In "myform.php", you put a line with "href" element like this:
    Code:
    <a href="myaction.php?param=value">go to action page</a>
    The param is any string you want, used to identify the parameter in the next page ("myaction.php"). So for your example, you put CELLNUMBER value substituting "value".

    Now in the "myaction.php" page, you get the value by using:
    Code:
    $_GET["param"];
    Of course, if you used other string other than param, simply replaced "param" with the text you used in "myform.php"

    For your information, you can also read about it in the PHP Manual.
    http://php.net/manual/en/reserved.variables.get.php
    Note the examples.

    Good luck!

  3. #3
    Join Date
    Nov 2012
    Location
    Jakarta
    Posts
    42

    Lightbulb The basics

    In order to pass it to the next page, you need to add it to the url that points to the next page.

    Let us say, your current page containing cellnumber is called "myform.php" and you want to pass it to "myaction.php".

    In "myform.php", you put a line with "href" element like this:
    Code:
    <a href="myaction.php?param=value">go to action page</a>
    The param is any string you want, used to identify the parameter in the next page ("myaction.php"). So for your example, you put CELLNUMBER value substituting "value".

    Now in the "myaction.php" page, you get the value by using:
    Code:
    $_GET["param"];
    Of course, if you used other string other than param, simply replaced "param" with the text you used in "myform.php"

    For your information, you can also read about it in the PHP Manual.
    http://php.net/manual/en/reserved.variables.get.php
    Note the examples.

    I am not familiar with the PHP structure you are using. I assume you are on some sort of framework. What I explained above is a concept, for implementation, you need to check with your framework.

    Good luck!

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,178
    Other alternatives are to save it as a session variable, or add it to a hidden form field (in case you are not locked down to it being a GET parameter due to interfacing with pre-existing code?).
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Jun 2011
    Location
    California
    Posts
    383

    Red face

    Thanks for all the replys, more examples will help me tremendously too! Happy new years guys!

  6. #6
    Join Date
    Jun 2011
    Location
    California
    Posts
    383
    Quote Originally Posted by NogDog View Post
    Other alternatives are to save it as a session variable, or add it to a hidden form field (in case you are not locked down to it being a GET parameter due to interfacing with pre-existing code?).

    How do you save it as a Session variable?

  7. #7
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,178
    Quote Originally Posted by Supplement View Post
    How do you save it as a Session variable?
    First script:
    PHP Code:
    <?php
    session_start
    ();

    $_SESSION['foo'] = 'bar';
    Second script:
    PHP Code:
    session_start();

    echo 
    $_SESSION['foo']; 
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  8. #8
    Join Date
    Jun 2011
    Location
    California
    Posts
    383
    So would foo be cellphone as thats the sql field name?

  9. #9
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,178
    It can be whatever you want it to be. $_SESSION is an array, to which you can add any number of elements -- even other arrays. It is "super-global", so you can access it just like you do $_GET or $_POST -- as long as you do session_start() first (and before any output of any type is sent to the browser).

    If you are unfamiliar with PHP sessions, definitely spend some time reading up on them, as they are a very useful tool for persisting data across multiple page requests.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  10. #10
    Join Date
    Nov 2012
    Posts
    23
    I think using the href is better than using session variable. Good explanation firesnaker.. thanks.

  11. #11
    Join Date
    Jun 2011
    Location
    California
    Posts
    383
    awesome guys! I figured it out and my url looks like so:

    &cellphone=%28444%29444-4444

    How do i strip the percentage signs and the array value 28 and 29?


    Here's my array:

    PHP Code:
    <?php echo "<td><a href='" matry::base_to('test/trace', array('patient_id' => $patient->id,'cellphone' => $patient->cellnumber)) . "'><ul class='controls'>
                        <li id='check_orders'><span class='symbols'>L</span><span class='label'>Skip Trace</span></li>
                        </ul></a></td>"
    ;?>

  12. #12
    Join Date
    Jun 2011
    Location
    California
    Posts
    383
    Should i Use : $url = urldecode($url);

    and if so how do i use that in the array?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles