Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to mantain information?

    Hi y'all!!

    Well, I have one page with some text boxes, and a submit button, the thing is that when they hit the submit button and enter to the next page they can go back and modify the data they have entered and not enter the whole information again.

    Hope someone can help me

    Thanks!!

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,793
    Thanks
    19
    Thanked 156 Times in 147 Posts
    Use some simple PHP validation on your text boxes so that important fields cannot be skipped over by the user and/or your text boxes only accept certain kinds of responses....something similar to this (you would need to change the variable names and the conditions of the IF statements):

    PHP Code:
    $errors 0;


    if (empty(
    $first_name))
    {
        echo 
    "<br><b>First Name</b> is a required field.";
        
    $errors++;
    }

    if (empty(
    $last_name))
    {
        echo 
    "<br><b>Last Name</b> is a required field.";
        
    $errors++;
    }

    if (empty(
    $email))
    {
        echo 
    "<br><b>E-mail</b> is a required field.";
        
    $errors++;
    }

    if (empty(
    $confirm_email))
    {
        echo 
    "<br><b>Confirm E-mail</b> is a required field.";
        
    $errors++;
    }

    if (
    $email != $confirm_email)
    {
        echo 
    "<br><b>E-mail</b> was entered incorrectly.";
        
    $errors++;
    }


    if (
    $errors 0)
    {
        echo 
    "<br><br>Please use your browser's back button to return to the form and fix any errors. <i>Thank you!</i><br><br>";
        exit();

    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #3
    Regular Coder
    Join Date
    Dec 2002
    Location
    UK
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    For this I assume your are POSTING the data and not GETTING it..

    PHP Code:

    <form name="form_name" method="post" action="somefile.php">

    <input type="text" name="some_name" value="<?php if (isset($_POST['some_value']) echo $_POST['some_value'];?>" />

    </form>
    You would replicate for all your form elements

    * edit: what this does is when the page loads it checks for the form values, to see if they are set. If they are, it displays the value.
    Last edited by bfsog; 06-29-2005 at 10:29 PM.

  • #4
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,793
    Thanks
    19
    Thanked 156 Times in 147 Posts
    Oops, yes do it bfsog's way, and also throw in a condition in there that states if the textbox value is set, then the textbox should be "greyed out" and "uneditable" (i can't remember how to do this....Google for it and find out)
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #5
    Regular Coder
    Join Date
    Dec 2002
    Location
    UK
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks chump.

    Hm, to make it read only, try

    PHP Code:
     <form name="form_name" method="post" action="somefile.php">

    <input type="text" name="some_name" value="<?php if (isset($_POST['some_value']) { echo $_POST['some_value'];?>" readonly="readonly" <?php ?> />

    </form>
    What that does is the same except, if the form value is set, it echo's the value and sets readonly to true.

  • #6
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,793
    Thanks
    19
    Thanked 156 Times in 147 Posts
    Actually, I think it would read like this?


    PHP Code:
    <form name="form_name" method="post" action="somefile.php">

    <input type="text" name="some_name" value="<?
     
    if (isset($_POST['some_value']))

       echo 
    $_POST['some_value'];
    }

    ?><?

    if (isset($_POST['some_value'])) 

       print 
    'readonly="readonly"';
    }

    ?>>

    </form>
    Last edited by chump2877; 06-30-2005 at 01:06 AM.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!


  •  

    Posting Permissions

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