Buonasera a tutti,
Purtroppo non ho mai studiato PHP ma me ne sto interessando e inizio a testarne le varie funzionalità.
Avrei un problema che sembra assilli parecchie persone.
Una pagina HTML dove ho il mio bel form, nel quale sono presenti anche radio button e check boxes.
Purtroppo quando vado sul lato PHP, questi non riesco a leggerli (ed una volta che provo ad inviarmi l'email con i dati contenuti nei campi questi risultano essere vuoti).
Codice HTML:
<!-- Checkbox (3) -->
<input type="checkbox" value="yes" name="check1" Checked/><label for="check1">Test1</label>  
<input type="checkbox" value="yes" name="check2" Checked/><label for="check2">Test2</label>  
<input type="checkbox" value="yes" name="check3" Checked/><label for="check3">Test3</label>  
<!-- Radio -->
<input type="radio" value="m" name="gender" />M  
<input type="radio" value="f" name="gender" />F
<!-- il resto l'ho omesso (tag base etc.)-->
Codice PHP:
<?php
if(isset($_POST['submit'])) //submit è il mio bottone POST nell'html
{
$myemail = 'miamail'; //per motivi di privacy l'ho rimossa ma è inserita correttamente
$subject = 'mioOggetto';
$gender = 'unknown';
$check1= ' ';
$check2 = ' ';
$check3= ' ';
if($_POST['gender'] == 'm') //questi sono due radio button (anche se seleziono M viene fuori "female" nell'email :c)
$gender = 'male';
else
$gender = 'female';
if($_POST['check1'] == 'yes') //checkbox 1 (ritorna valore nullo seppur selezionato, stessa cosa per le altre 2)
$check1 = 'X';
else
$check1 = ' ';
if($_POST['check2'] == 'yes')
$check2 = 'X';
else
$check2 = ' ';
if($_POST['check3'] == 'yes')
$check3 = 'X';
else
$check3 = ' ';
$emailbody = 'First Name: '.$_POST['name']."\n"
.'Last Name: '.$_POST['lastname']."\n"
.'Email: '.$_POST['email']."\n"
.'Gender: '.$gender."\n"
.'Checks - 1:'.$check1.' 2:'.$check2.' 3:'.$check3."\n";
.'Data: '.$_POST['date2'].'/'.$_POST['date1'].'/'.$_POST['date3']."\n" //con la data non ho problemi
.'Comments: '.$_POST['comments']."\n";
mail($myemail, $subject, $emailbody);
header('location: thankyou.html');
}
else
{
header('location: index.html');
}
?>
Grazie mille <3