This if() statement:
if ( $value = "" )
doesn't do what you (probably) think it does; you're telling PHP to set the value of $value equal to "". I believe you meant to use the comparison operator, ==, perhaps?
EDIT: Also, why are you outputting Javascript code? If you really want to use Javascript code, then use the full benefit of Javascript - do the value checks on the client-side before the form is submitted. Since standard security practice dictates that Javascript/client-side scripting can never be trusted, however, you should also leave the duplicate check in your PHP code.
EDIT2: Also, allowing the From header to be specified by user-input (e.g. the user's e-mail address) is a very bad practice; it will most likely get you labeled as an open relay and blocked by many SMTP servers and/or RBLs. The From header should always be a valid e-mail address at your domain; if you want to incorporate the user's e-mail address, do so in a "Reply-To:" header instead.