ok i am at a loss but this shouldn't be too hard. for all of you smarties

ok i am tiered of building forms just to have to go though and grab every name and slowly and pain fully build the php part. what i would like to do is put my code in a php file and cycle through the code and grab every name attribute in an input, radio box, or any form field and print it out as so as a loop.

input type=\"text\" class=\"input\" name=\"homephone\"

$homephone = $ _ POST ;

i might just be retarded. haha.

thanks anyone

That would be a waste of time really. Its easier to use arrays and dynamic variables.

You can do:

foreach( $_POST as $key => $val ) {
  ${$key} = mysql_real_escape_string( htmlentities( $val ) );
}

that will put all the post data into usable variables.

That would be a waste of time really. Its easier to use arrays and dynamic variables.

You can do:

foreach( $_POST as $key => $val ) {
  ${$key} = mysql_real_escape_string( htmlentities( $val ) );
}

that will put all the post data into usable variables.

That looks great but i don't know what that all would do. i have found a foreach that looks like this. i am still a novice at somethings. plus that code gives me a

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in

foreach($_POST as $name => $value){
 echo '&#36;'.$name.' &#61; &#36;_POST&#91;&#39;'.$name.'&#39;&#93;;<br />';
}

You need to connected to a database before mysql_real_escape_string() will work.

Also, the foreach you posted won't work.

You need to connected to a database before mysql_real_escape_string() will work.

Also, the foreach you posted won't work.

ok i will connect to a DB and test it. and the for each that i gave does work .i just used the html characters like & nbsp; but i have to put the code in the form and run it instead of putting it in a text area and then running it.

This article has been dead for over six months. Start a new discussion instead.