ecco perchè
Dunque direi che non ha senso costruire questa funzione nel file php, ma bensì nel form.
Ecco cosa ho fatto:
Form
codice:
<td>Città:</td>
<td><select name="categoria">
<?php
$c=mysql_connect ("server", "root" , "root");
mysql_query ("use database", $c);
$sql="select * from newsletter_categories where id >1 order by name";
$dati=mysql_query($sql);
while($riga=mysql_fetch_array($dati))
{
echo "<option value=" . $riga['id'] .">" . $riga['name'] ."</option>";
}
?>
pagina php:
codice:
$to = "mail@gmail.com";
$subject = "Un nuovo contatto mail INSERITO alla Newsletter";
$body .= "Un nuovo utente si è ISCRITTO alla Newsletter: " . trim(stripslashes($_POST["email1"])) . " In questa Città: " . trim(stripslashes($_POST["categoria"])) . "\n";
$headers = "From: Modulo Controllo Newsletter. <info@mail.com>";
mail($to, $subject, $body, $headers);
Solo che nella mail ovviamente mi riporta l'id e non il nome e non posso modificare sul form questo:
codice:
echo "<option value=" . $riga['id'] .">" . $riga['name'] ."</option>";
in questo:
codice:
echo "<option value=" . $riga['name'] .">" . $riga['name'] ."</option>";
Cosa suggerisci?