www.webdeveloper.com
Results 1 to 4 of 4

Thread: changing the value of a $_post or something?

  1. #1
    Join Date
    Jun 2004
    Posts
    1,299

    Question changing the value of a $_post or something?

    Hi,

    I am trying to get it so that when it echos out the message, it will echo out instead of FN, First Name.

    I dont want it to change FN as i still want to reffer to it as $_POST[FN];, i just want $key to say a different name, perhaps there is a way i can create an asigned name or tempery name.

    Here is my code
    PHP Code:
    <?PHP

    if ($_GET[validate] == 1) {
        
        foreach(
    $_POST as $key => $val) {
            
    // make sure it is filled out
            
    if (empty($val)) {            
                
    $error_msg "$key must be filled in.\n";
                
    $errors true;
            }
        }
    }

    ?>
    <html>
    <body>
    <!-- Page Errors -->
    <?php if(isset($errors) && $errors){ ?> 
    <?php echo $error_msg; } ?>

    <form method="post" action="<?PHP $_SERVER['PHP_SELF']; ?>?validate=1">
        <input name="FN" type="text">
        <input name="" type="submit" value="Submit">
    </form>
    </body>
    </html>
    Any ideas

    Thanks
    Adam

  2. #2
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,972
    Riiight, I think this is what you're getting at:
    PHP Code:
    <?php
    //Form an array of descriptions for each field
    $desc['FN'] = 'first name';
    $desc['LN'] = 'last name';
    //Your thing again
    foreach($_POST as $key => $val) {
    if (empty(
    $val)) {            
    $error_msg "$desc[$key] must be filled in.\n";
    $errors true
    ?>
    Disclaimer. (1) Whilst I will help you sometimes, if I feel like it, and my advice in relation to your actual question will be of good quality: my posts are to be taken with a pinch of salt. I will be sarcastic, deploy irony and include obscure cultural references for my own amusement without warning.
    (2) You will gain nothing from complaining, and if you try to argue with me then you will not win. No matter how noble your battle seems, I am still better than you, don't be an hero.

  3. #3
    Join Date
    Jun 2004
    Posts
    1,299
    AHHH!!

    Yes, i shoulda thought of that!

    Thanks
    Adam
    Last edited by k0r54; 02-19-2005 at 04:52 AM.

  4. #4
    Join Date
    Jun 2004
    Posts
    1,299
    a

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