Męczę się od dłuższego czasu z takim problemem. Wyklepałem to
kontakt.php
Kod
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head lang="pl">
<title>Kontakt</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css">
<!--
*{
margin:0;
padding:0;
}
.tresc_form{
margin-bottom:25px;
margin-left:20px;
font-family:Arial;
font-size:10px;
color:#999999;
}
.tresc_form_alert{
margin-bottom:25px;
margin-left:20px;
font-family:Arial;
font-size:10px;
color:#FF0000;
}
.tresc_form_SendTo{
margin-bottom:25px;
margin-left:20px;
font-family:Arial;
font-size:16px;
color:#FF9933;
}
.tresc_normal{
font-family:Arial;
font-size:12px;
color:#333333;
}
#formularz{
margin-left:25px;
}
-->
</style>
</head>
<body>
<div id="formularz">
<form action="kontakt.php" method="post">
<?php
/*---------------------------------------------------------*/
$email = stripslashes($_REQUEST['email']);
$tresc = stripslashes($_REQUEST['tresc']);
/*-------------------------WALIDACJA--------------------------------------*/
function IsValidEmail($email, $tresc) {
if(empty ($tresc) and empty ($email)) {
echo '
<p class="tresc_normal">E-mail:<br><input name="email" type="text" value="'.$email.'" size="30" maxlength="30"></p>
<p class="tresc_form">(wpisz pełny adres e-mail)</p>
<p class="tresc_normal">Wiadomość:<br><textarea name="tresc" cols="50" rows="5">'.$tresc.'</textarea></p>
<p class="tresc_form">(tu wpisz treść wiadomości)</p>
<p><input name="submit" type="submit" value="Wyślij"></p>
';
}
else if(!preg_match('/^([0-9a-zA-Z_\.]+)@([0-9a-zA-Z_\.]+)\.([0-9a-zA-Z]){2,3}$/',$email)) {
// echo "Podany adres e-mail nie jest prawidłowy ";
echo '
<p class="tresc_normal">E-mail:<br><input name="email" type="text" value="'.$email.'" size="30" maxlength="30"></p>
<p class="tresc_form_alert">Podany adres e-mail nie jest prawidłowy</p>
<p class="tresc_normal">Wiadomość:<br><textarea name="tresc" cols="50" rows="5">'.$tresc.'</textarea></p>
<p class="tresc_form">(tu wpisz treść wiadomości)</p>
<p><input name="submit" type="submit" value="Wyślij"></p>
';
}
else {
IsValidTresc($tresc, $email);
}
}
IsValidEmail($email, $tresc);
function IsValidTresc($tresc, $email) {
if(empty ($tresc)) {
echo '
<p class="tresc_normal">E-mail:<br><input name="email" type="text" value="'.$email.'" size="30" maxlength="30"></p>
<p class="tresc_form">(wpisz pełny adres e-mail)</p>
<p class="tresc_normal">Wiadomość:<br><textarea name="tresc" cols="50" rows="5">'.$tresc.'</textarea></p>
<p class="tresc_form_alert">Nie wpisano żadnej treści do wysłania.</p>
<p><input name="submit" type="submit" value="Wyślij"></p>
';
}
else {
echo '<p class="tresc_form_SendTo">Dziękujemy za wypełnienie formularza.</p>';
SendTo($tresc, $email);
}
}
/*-------------------------WALIDACJA--------------------------------------*/
function SendTo($tresc, $email){
$do_kogo = "marek <marek@wp.pl>";
$temat = 'Kontakt , '.$email;
$wiadomosc = '
<html>
<head>
<title>Zadaj pytanie</title>
</head>
<body>
<p>'.$tresc.'<br><hr>
Nadawca:<b> '.$email.'</b>
</p>
</body>
</html>
';
$naglowki .= "MIME-Version: 1.0\n";
$naglowki .= "Content-type: text/html; charset=utf-8\n";
mail($do_kogo, $temat, $wiadomosc, $naglowki);
}
?>
</form>
</div>
</body>
</html>
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head lang="pl">
<title>Kontakt</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css">
<!--
*{
margin:0;
padding:0;
}
.tresc_form{
margin-bottom:25px;
margin-left:20px;
font-family:Arial;
font-size:10px;
color:#999999;
}
.tresc_form_alert{
margin-bottom:25px;
margin-left:20px;
font-family:Arial;
font-size:10px;
color:#FF0000;
}
.tresc_form_SendTo{
margin-bottom:25px;
margin-left:20px;
font-family:Arial;
font-size:16px;
color:#FF9933;
}
.tresc_normal{
font-family:Arial;
font-size:12px;
color:#333333;
}
#formularz{
margin-left:25px;
}
-->
</style>
</head>
<body>
<div id="formularz">
<form action="kontakt.php" method="post">
<?php
/*---------------------------------------------------------*/
$email = stripslashes($_REQUEST['email']);
$tresc = stripslashes($_REQUEST['tresc']);
/*-------------------------WALIDACJA--------------------------------------*/
function IsValidEmail($email, $tresc) {
if(empty ($tresc) and empty ($email)) {
echo '
<p class="tresc_normal">E-mail:<br><input name="email" type="text" value="'.$email.'" size="30" maxlength="30"></p>
<p class="tresc_form">(wpisz pełny adres e-mail)</p>
<p class="tresc_normal">Wiadomość:<br><textarea name="tresc" cols="50" rows="5">'.$tresc.'</textarea></p>
<p class="tresc_form">(tu wpisz treść wiadomości)</p>
<p><input name="submit" type="submit" value="Wyślij"></p>
';
}
else if(!preg_match('/^([0-9a-zA-Z_\.]+)@([0-9a-zA-Z_\.]+)\.([0-9a-zA-Z]){2,3}$/',$email)) {
// echo "Podany adres e-mail nie jest prawidłowy ";
echo '
<p class="tresc_normal">E-mail:<br><input name="email" type="text" value="'.$email.'" size="30" maxlength="30"></p>
<p class="tresc_form_alert">Podany adres e-mail nie jest prawidłowy</p>
<p class="tresc_normal">Wiadomość:<br><textarea name="tresc" cols="50" rows="5">'.$tresc.'</textarea></p>
<p class="tresc_form">(tu wpisz treść wiadomości)</p>
<p><input name="submit" type="submit" value="Wyślij"></p>
';
}
else {
IsValidTresc($tresc, $email);
}
}
IsValidEmail($email, $tresc);
function IsValidTresc($tresc, $email) {
if(empty ($tresc)) {
echo '
<p class="tresc_normal">E-mail:<br><input name="email" type="text" value="'.$email.'" size="30" maxlength="30"></p>
<p class="tresc_form">(wpisz pełny adres e-mail)</p>
<p class="tresc_normal">Wiadomość:<br><textarea name="tresc" cols="50" rows="5">'.$tresc.'</textarea></p>
<p class="tresc_form_alert">Nie wpisano żadnej treści do wysłania.</p>
<p><input name="submit" type="submit" value="Wyślij"></p>
';
}
else {
echo '<p class="tresc_form_SendTo">Dziękujemy za wypełnienie formularza.</p>';
SendTo($tresc, $email);
}
}
/*-------------------------WALIDACJA--------------------------------------*/
function SendTo($tresc, $email){
$do_kogo = "marek <marek@wp.pl>";
$temat = 'Kontakt , '.$email;
$wiadomosc = '
<html>
<head>
<title>Zadaj pytanie</title>
</head>
<body>
<p>'.$tresc.'<br><hr>
Nadawca:<b> '.$email.'</b>
</p>
</body>
</html>
';
$naglowki .= "MIME-Version: 1.0\n";
$naglowki .= "Content-type: text/html; charset=utf-8\n";
mail($do_kogo, $temat, $wiadomosc, $naglowki);
}
?>
</form>
</div>
</body>
</html>
pewnie są błędy techniczne ale co tam działa ładnie ;p
Btw. Plik działa jeżeli wywołam jego samego. Ew. niepoprawne zmienne są zwracane i niema konieczności wypełniania formularza ponownie. Jak teraz wykombinować przekazywanie zmiennych jeżeli ten plik jest includowany ?
wygląda to standardowo
include nagłówek z menu
include jakaś strona wczytywana z menu nagłówka
include stopka
probowałem zmienić ten wpis
Kod
input name="submit" type="submit" value="Wyślij">
na a href ze zmiennymi get ale wywalało puste wartości i plik kontakt.php ładował się na całym oknie bez stopki i nagłówka
W php programuję od niedawna ale nie potrzebuje kodu tylko jakiegoś namiaru jak to wykonać, czego użyć. HELP
