Forum Webmasterskie: Formularz kontaktowy - Forum Webmasterskie

Skocz do zawartości

Strona 1 z 1
  • Nie możesz napisać tematu
  • Nie możesz odpowiedzieć

Formularz kontaktowy

#1 Użytkownik nie jest zalogowany   Michael2318 Ikona

  • Przedszkolak
  • Pip
  • Grupa Members
  • Postów 2
  • Rejestracja 11-maj 11

Napisano 11 maj 2011 - 05:22

Witam!

Piszę właśnie swoją pierwszą stronę internetową i umieściłem na niej także formularz kontaktowy. Niestety nie obeszło się bez PHP.

Część mojego kodu wygląda tak:

<p><center><form method="post" action="wyslij.php" name="kontakt">
<table width="100%" cellspacing="1" cellpadding="1" border="0">
    <tbody>
        <tr>
            <td style="padding-left:10px;"><div><label for="nick">Imię i nazwisko:<font color="red">*</font></label></span></td>
            <td style="padding-right:400px;"><ul><input type="text" class="text" id="podt" name="nick" ></div></span></td>
        </tr>
        <tr>
            <td style="padding-left:10px;"><div><label for="temat">Temat: <font color="red">*</font></label></td>
            <td style="padding-right:400px;"><ul><input type="text" name="temat" class="text" id="podtt" ></div></td>
        </tr>
        <tr>
            <td style="padding-left:10px;"><div><label for="text">Adres e-mail: <font color="red">*</font></label></td>
            <td style="padding-right:400px;"><ul><input type="text" name="mail" class="text" id="podttt" ></div></td>
        </tr>
        <tr>
            <td style="padding-left:10px;"><div><label for="tresc">Tre&#347&#263: <font color="red">*</font></label></td>
            <td style="padding-right:400px;"><ul><textarea name="tresc" id="tresc" rows="5" cols="50" ></textarea></div></td>
        </tr>
    </tbody>
</table>
<input type="submit" name="submit_button" value="Wy&#347lij" class="button_l" id="wyslij" onclick="this.form.submit(); post.message.value=''; return false;">
<input type="reset" name="reset" value="Wyczy&#347&#263" class="wyczysc" id="wyczysc">
<br>
<br>
<center>
<font color="red">*</font> - Pola Wymagane!
</center>
</form>
</span>
</center></p>


Jak widać, w pierwszej linijce tego kodu, odwołuję się do pliku wyslij.php, który wygląda następująco:

<?php
if (empty($_POST['nick']))
{     
echo "Nie uzupełniłes wszystkich rubryk!"; 
exit;  
} 
if (empty($_POST['mail']))
{     
echo "Nie uzupełniłes wszystkich rubryk!"; 
exit;  
} 
if (empty($_POST['tresc']))
{     
echo "Nie uzupełniłes wszystkich rubryk!"; 
exit;  
} 
if (empty($_POST['temat']))
{     
echo "Nie uzupełniłes wszystkich rubryk!"; 
exit;  
} 
$wiadomosc = 
"Imie: ".$_POST['nick']." 

e- mail: ".$_POST['mail']." 

Tresc: ".$_POST['tresc']."  "; 

$tematyka = "".$temat;


mail ("michael23318@gmail.com", $tematyka, $wiadomosc ); 
echo "Dziekujemy za wyslanie do nas wiadomosci!"; 
?>



I teraz mój problem polega na tym, że obojętnie czy użytkownik wypełni wszystkie pola, czy też nie, informacja z błędem wyświetla się na czystej, białej stronie, z wiadomych przyczyn. Jeśli dodam do wyslij.php, kod html strony, czyli będzie to wyglądało tak:

<?xml version="1.0" encoding="iso-8859-2"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="application/xhtml+xml; charset=iso-8859-2" />
<meta http-equiv="Content-Language" content="pl" />
<title>Support by Michael2318 - Kontakt</title>
<link rel="stylesheet" href="style.css">
</head>
	<body xml:lang="pl">
		<div id="top">
			<ul>
				<li><a href="index.htm">Home</a></li>
				<li><a href="omnie.htm">O mnie</a></li>
				<li><a href="oferta.htm">Oferta</a></li>
				<li><a href="cennik.htm">Cennik</a></li>
				<li><a href="kontakt.htm">Kontakt</a></li>
			</ul>
			
			<h1 style="margin:0px;"><a href="index.htm">Michael2318</a></h1>
		</div>
<div id="kontener">
		<div id="tresc">
		<div style="padding-left:20px;" class="lewo"><div class="trescPad">

<?php
if (empty($_POST['nick']))
{     
echo "Nie uzupełniłes wszystkich rubryk!"; 
exit;  
} 
if (empty($_POST['mail']))
{     
echo "Nie uzupełniłes wszystkich rubryk!"; 
exit;  
} 
if (empty($_POST['tresc']))
{     
echo "Nie uzupełniłes wszystkich rubryk!"; 
exit;  
} 
if (empty($_POST['temat']))
{     
echo "Nie uzupełniłes wszystkich rubryk!"; 
exit;  
} 
$wiadomosc = 
"Imie: ".$_POST['nick']." 

e- mail: ".$_POST['mail']." 

Tresc: ".$_POST['tresc']."  "; 

$tematyka = "".$temat;


mail ("michael23318@gmail.com", $tematyka, $wiadomosc ); 
echo "Dziekujemy za wyslanie do nas wiadomosci!"; 
?>
		</div></div>
		<div style="padding-right:20px;" class="block float"><div class="trescPad prawaTabela">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p><br><br>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p><br><br>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
		</div></div>

		</div>
		<div id="stopka">
		<div class="stopkaPad">
<p>Copyright by <b>Michael2318</b> - Wszelkie prawa zastrzeżone.</p>
		</div>
		</div>

		</div>
	</body>
</html>



To wtedy nie ma tła pod informacją, nie wiem czemu? Strona wygląda tak:

Dołączona grafika

A w przypadku wyslij.php, z tym kodem html tak:

Dołączona grafika

I czemu pod tym napisem nie ma tła ??

Pozdrawiam!
Michał,
0

#0 Reklama

  • WebForum.pl
  • Grupa Advert

Napisano --



#2 Użytkownik nie jest zalogowany   mervin Ikona

  • Administrator
  • Ikona
  • Grupa Administrators
  • Postów 143
  • Rejestracja 17-lipiec 09

Napisano 11 maj 2011 - 05:40

Dzieje się tak najprawdopodobniej przez to, że występuje "exit" przy pętlach. W wypadku nieuzupełnienia pola strona nie generuje się do końca. Sprawdź źródło strony która wyświetla się w przypadku gdy nieuzupełnione są wszystkie pola. Jeżeli kod kończy się na
<div style="padding-left:20px;" class="lewo"><div class="trescPad">
to masz odpowiedź :)
0

#3 Użytkownik nie jest zalogowany   Michael2318 Ikona

  • Przedszkolak
  • Pip
  • Grupa Members
  • Postów 2
  • Rejestracja 11-maj 11

Napisano 11 maj 2011 - 13:48

Możesz trochę jaśniej? Mam pokazać .css ??
0

Strona 1 z 1
  • Nie możesz napisać tematu
  • Nie możesz odpowiedzieć

Użytkownicy przeglądający ten temat: 1
0 użytkowników, 1 gości, 0 anonimowych