0

User fills out certain values in a form and hits the submit button.
The values the user filled out will be submitted to the database.
The user needs to come back to that form and be able to update the values he did not enter the first time.
How would i do this with PHP?

7
Contributors
11
Replies
80
Views
3 Years
Discussion Span
Last Post by brandon66
0

There's alot of coding to do with regard to your description. I'd recommend that you break this up into components/phases.

Start with the HTML. Do you have those pages already created? If so, any issues? Once you have the completed, then proceed with designing the PHP components.

First step is to submit the values to a PHP page to process the input and submit it to the DB. Do you have that done? etc..etc...

0

Yes i have all this done already it just trying to come back and update it once the forms been submitted.
HTML
PHP

0

To be honest, I am afraid I'm a little too newbie for this, but it's obvious that in your php you need a loop that re-renders the page with validation (indicating which fields are missing) until the information is complete no? <ducks> :) >

0

why you want that user fill form again use validation and force user to fill form in first attempt what filleds are require give validation on that

0

you can do it by ... if statement like for e.g.

<?php
$sql="select * from user where id=12";
$raw=mysql_query($sql);
if(mysql_nums_rows($raw)>0){
    $data=mysql_fetch_array($raw);
    ?>
    <form>
        Name <input type='text' name='a1' value='<?php echo $data['name']?>'/>
        Email <input type='text' name='a2' value='<?php echo $data['email']?>'/>
        Company <input type='text' name='a3' value='<?php echo $data['company']?>'/>

    </form>

<?php

}
else
{
    ?>
    <form>
        Name <input type='text' name='a1' >
        Email <input type='text' name='a2' >
        Company <input type='text' name='a3' >'/>

    </form>


    <?php

}

?>

here is the demo e.g. for you .... you can reffer it ...

0

Yes there is, however the most valid point that has been made this far is that the theory behind this is bizare.

All you would have to do is input the data to the database then re-print the page to the document looping through each feild and seeing what was posted last time using the $_POST global variables for instance.

if( strlen( $_POST['name'] ) > 0 ) {
    echo 'Name: <input type="text" name="name" value="' . stripslashes( $_POST['name'] ) . ' />';
} else {
    echo '<span style="color: red">This field is required...</span>';
    echo '<br />';
    echo 'Name: <input type="text" name="name" />';
}

BUT why would you want to input it to the database at all until you have a full data set and verified the data within it?

0

There will be a test and only some of the values the tester is able to get so some of the fields are optional so the values the user filled out is stored in the database for use in the thorough test of the unit. Then the units information will get updated(the information that was not filled out) The unit itself has to go through the thorough test before its able to get more information about the unit

0

Would anyone point me in the right direction to set this up with Ajax?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.