Results 1 to 25 of 25

Thread: $_post

  1. #1

    Thread Starter
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616

    $_post

    I used the following code to get variable sent via a form but now I am wondering if I can get the variable names too so I can display it nicely in an email.

    PHP Code:
    <?php
        
    if (isset($submit)) {
            foreach(
    $_POST as $i) {
                print 
    "$i<br>";
            }
        }
    ?>
    -Matt
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Wont that display the value of each? Or is that what you're trying to accomplish?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Nevermind, you already knew that...
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4

    Thread Starter
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    Here is a test script of what information that code gets, I want to get the name="" attribute too and not just the value=""

    http://cpradio.net/Test.php

    -Matt
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  5. #5
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Try this:

    PHP Code:
    <?php
    if (isset ($submit)) {
        while (list (
    $name$value) = each ($_POST)) {
            echo 
    "$name == $value<br>\n";
        }
    }
    ?>
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6

    Thread Starter
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    that didnt work
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  7. #7
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    This works for me:

    PHP Code:
    <?php
        
    if ($action == 'show') {
            while (list (
    $name$value) = each ($_POST)) {
                echo 
    "$name == $value<br>\n";
            }
        } else {
            echo 
    '<form action="work.php" method="post">
            <input type="hidden" name="action" value="show">
            <input type="text" name="fun"><br>
            <input type="submit">
            </form>'
    ;
        }
    ?>
    My evil laugh has a squeak in it.

    kristopherwilson.com

  8. #8
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    you can see it here: http://www.vbshelf.com/work.php
    My evil laugh has a squeak in it.

    kristopherwilson.com

  9. #9

    Thread Starter
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    ahh, it works. I had placed your code beneath mine and it wouldn't run b/c the pointer was at the end of $_Post
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  10. #10
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    So everything is good?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  11. #11

    Thread Starter
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    yep, now i have a universal contact form/anything you want form
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  12. #12
    scoutt
    Guest
    FYI

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

    if globals are turned off then submit will not get noticed. submit is just like any other variable from a form.

  13. #13
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Same thing for ACTION, Hobo.

    PHP Code:
    if ($_POST['action'] == 'show') { 
    OKAY?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  14. #14

    Thread Starter
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    Originally posted by scoutt
    FYI

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

    if globals are turned off then submit will not get noticed. submit is just like any other variable from a form.
    In later versions will globals be turned off automatically?

    Hobo: I dont plan on using action as its just a worthless slot for me. I just plan on using that code to create Emails on the fly from any form.

    -Matt
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  15. #15
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by cpradio


    In later versions will globals be turned off automatically?

    Hobo: I dont plan on using action as its just a worthless slot for me. I just plan on using that code to create Emails on the fly from any form.

    -Matt
    Yes, starting in 4.2, it will be turned off by default.

    Matt:That post was directed at myself. Not you.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  16. #16

    Thread Starter
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    oh okay

    Will the option to turn them on still be existant or is it forcing them to be off?
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  17. #17
    scoutt
    Guest
    you can still turn them on, but it is not recommended for security and speed issues.

  18. #18
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I've grown to love the superglobals anyways
    My evil laugh has a squeak in it.

    kristopherwilson.com

  19. #19

    Thread Starter
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    damn, i now have to rewrite about 40 pages of code
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  20. #20

    Thread Starter
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    wait maybe not, is there any way to force globals on at runtime?
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  21. #21
    scoutt
    Guest
    yes you can set the globals on at runtime,

    ini_set("register_globals", 1);

    that iwll set it to 1, which is on. 0 is off.

  22. #22
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    You could mimic it by using the code I gave you below:

    PHP Code:
    <?php
        
    while (list ($name$value) = each ($_POST)) {
            
    //something
        
    }
    ?>
    Okay, I can't remember how to do it. I'll get back to you.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  23. #23

    Thread Starter
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    Well, the reason I asked is with ini_set("register_globals",1); I can now go back to my old php scripts add that line and not worry about them not working in 4.2
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  24. #24
    scoutt
    Guest
    I would test it first on a couple of pages first before your whole site. I tried a couple of other things like that and I remember having issues since the master setting was the other way.

  25. #25

    Thread Starter
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    im almost positive my hosting service will have them on as its more convinent, so im not too worried.

    but when the switch occurs I will test it locally first.

    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

Posting Permissions

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



Click Here to Expand Forum to Full Width