Can someone tell me why this isn't a good way to assign $_POST vars?
<p>I am wondering if anyone can suggest a more elegant way to assign variables during PHP/mySQL form submission.  This seems clunky </p>

<pre>

    //include("connect.php");
        mysql_connect("localhost","root","root");
        mysql_select_db("noirTEST");
        // assign out vars from the POST vars to get ready for SQL insertion
        $thumb_image_location = $_POST['thumb_image_location'];
        $large_image_location = $_POST['large_image_location'];
        $password = sanitizeString($_POST['password1']);
        $firstName = sanitizeString($_POST['firstName']);
        $lastName = sanitizeString($_POST['lastName']);
        $desc_short = sanitizeString($_POST['desc_short']);
        $nationality = sanitizeString($_POST['nationality']);
        $speakEnglish = sanitizeString($_POST['speakEnglish']);
        $speakGerman = sanitizeString($_POST['speakGerman']);
        $mainInst = sanitizeString($_POST['mainInst']);
        $inspiration1 = sanitizeString($_POST['inspiration1']);
        $inspiration2 = sanitizeString($_POST['inspiration2']);
        $inspiration3 = sanitizeString($_POST['inspiration3']);
        $inspiration4 = sanitizeString($_POST['inspiration4']);
        $inspiration5 = sanitizeString($_POST['inspiration5']);
        $desc_long = sanitizeString($_POST['desc_long']);
        $link1name = sanitizeString($_POST['link1name']);
        $link1url = sanitizeString($_POST['link1url']);
        $link2name = sanitizeString($_POST['link2name']);
        $link2url = sanitizeString($_POST['link2url']);
        $link3name = sanitizeString($_POST['link3name']);
        $link3url = sanitizeString($_POST['link3url']);
        $email = sanitizeString($_POST['email']);
        $proExperience = sanitizeString($_POST['proExperience']);
        $haveStudio = sanitizeString($_POST['haveStudio']);
        $musicTheory = sanitizeString($_POST['musicTheory']);
        $composer = sanitizeString($_POST['composer']);
        $teacher = sanitizeString($_POST['teacher']);

        $query = "INSERT INTO NOIRusers (thumb_image_location, large_image_location, password, firstName, lastName, desc_short, nationality, speakEnglish, speakGerman, mainInst, inspiration1, inspiration2, inspiration3, inspiration4, inspiration5, desc_long, link1name, link1url, link2name, link2url, link3name, link3url, email, proExperience, haveStudio, musicTheory, composer, teacher ) VALUES ('$thumb_image_location', '$large_image_location', '$password', '$firstName', '$lastName', '$desc_short', '$nationality', '$speakEnglish', '$speakGerman','$mainInst',  '$inspiration1', '$inspiration2', '$inspiration3', '$inspiration4', '$inspiration5', '$desc_long', '$link1name', '$link1url', '$link2name', '$link2url', '$link3name', '$link3url', '$email', '$proExperience', '$haveStudio', '$musicTheory', '$composer', '$teacher')";

    function sanitizeString($string)
        {
            $string=trim($string);
            $string=strip_tags($string);
            $string=htmlentities($string);
            $string=stripslashes($string);
            return $string;
        };

</pre>

<p>Would something like this work for the long first part?</p>

<pre><code>foreach($_POST as $key =&gt; $value){
    ${$key} = $value;
    sanitizeString($key);
}
</code></pre>

<p>It seems like every example I am seeing uses the long way or something like it .. so I am sure there is a reason why a shorter way can't / shouldn't be used.  But can anyone explain it to me?</p>
