dobra już poprawiłem wszystko, lecz zacząłem rozszerzać swój skrypcik i natrafiłem na kolejne problemy ...
nie zachowuje wprowadzonych danych, nie wysyła emaila, nie działa walidacja :/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Zrób ze mnie Elvisa - Wysyłanie wiadomości</title>
</head>
<body>
<?php
if (isset($_POST['submit'])) { // sprawdza wartosc zmiennej submit, jesli user nie przeslal formularza to zmienna ta nie bedzie ustawiona $email_to = "kafar610@gmail.com";
$email_subject = "Your email subject line";
$output_form = false; //jesli false to nie wyswietlamy
$nick = $_POST['nick'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$other = $_POST['other'];
echo 'Uzupełnij wszystkie pola<br />'; $output_form = true; // jesli true to wyswietlamy formularz
}
echo 'Nie podałeś imienia i nazwiska.<br />'; $output_form = true;
}
echo 'Nie podałeś emaila<br />'; $output_form = true;
}
echo 'Nie zadałeś pytania<br />'; $output_form = true;
}
}
else{
$output_form = true; // jesli skrypt nie udospetnil formularza to koniecznie trrzeba to zrobic zmienna $isset
}
$msg = "Imię i nazwisko: $name\n" .
"email: $email\n" .
"telephone: $telephone\n" .
"Inne komentarze: $other";
$headers = 'From: ' . $_POST['email'] . "\r\n" .
'Content-type: text/html; charset=utf-8';
mail($email_to, $email_subject, $msg, $headers); }
if ($output_form) { // sprawdza wartosc zmiennej $output_form jesli true to wyswietla formularz
?>
<form name="contactform" method="post" action="
<?php echo $_SERVER['PHP_SELF']; ?>">
<table width="750px" cellspacing="10">
<tr>
<td valign="top">
<label for="nick">Imię i nazwisko *</label>
</td>
<td valign="top">
<input type="text" name="nick" maxlength="50" value="
<?php echo $name; ?>" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="email">Adres e-mail *</label>
</td>
<td valign="top">
<input type="text" name="email" maxlength="80" value="
<?php echo $email; ?>" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="telephone">Numer telefonu</label>
</td>
<td valign="top">
<input type="text" name="telephone" maxlength="30" value="
<?php echo $telephone; ?>" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="other">Pytania, uwagi *</label>
</td>
<td valign="top">
<textarea name="other" maxlength="1000" cols="25" rows="6">
<?php echo $other; ?></textarea>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<input type="submit" value="Submit">
</td>
</tr>
</table>
</form>
<?php
}
?>
</body>
</html>