Naming form fields on a web page

How do you name your field names on a web page without revealing the structure of the database tables?

+5
source share
4 answers

Just name them something else in HTML and manually match the database field names with the HTML field names in your PHP code.

But really, if you use the prepared instructions and perform the correct authorization and error checking, it should not be important whether people know the names of the table fields.

+3
source

, , , . SQL.

.

, ( SQL-) , , .

+2

/.

, , , tx_field_name, , html, hf_field_name html hx_field_name... script , .

- , , , , foo, bar , _ - ( html-, )

p.s: , ,

$values = $_POST;
$n_val = count($values);
$i = 0;
foreach($values AS $key => $value){
    $pairs .= " `$key` = '$value' ";
    if($n_val > $i){
        $pairs .= ', ';
    }
}
thedbyouprefer_query("UPDATE table SET $pairs WHERE id = '42'");

to process the form, but matching it with php (.. and a few prepared racks will not be bad)

+2
source

If this really bothers you, then just user1, field2 (or f1, f2) and map them to your database fields in your book. But, if you do not use database calls from your HTML code, then there is very little that you can learn about the database structure itself by simply looking at the forms with field names than without.

+1
source

All Articles