954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP form is not sending the message

Hi everyone,

I have problem with form at my site. When you fill the text boxes it works fine but when you click SEND, the site is refreshing, form is clear and no message has been sent. My knowledge about PHP is very low. I found the tutorial which shows how to make that kind of form. I watched it 3 times and till now I don't know what is wrong.

form is on this site --> www.hogar-biokominki.pl/jak_kupic.html

I have 3 files which whould operate the form.

formularz.php

<div class="form" <? if(isset($_POST['sender'])) { echo "style=\"display:none;\""; } ?>>
	  <form action="" method="post" id="form1">
      <input type="hidden" name="sender" value="true">
            <fieldset>
              <legend>Formularz kontaktowy</legend>
              <li><span id="sprytextfield1">
              <label for="imieinazwisko">Imię i Nazwisko:</label>
              <input name="imieinazwisko" type="text" id="imieinazwisko" tabindex="1" maxlength="30">
              <span class="textfieldRequiredMsg">Pole wymagane</span><span class="textfieldMinCharsMsg">Za mało znaków</span></span></li>
              <li><span id="sprytextfield2">
              <label for="adresemail2">Adres e-mail:</label>
              <input type="text" name="adresemail" id="adresemail2" tabindex="2">
              <span class="textfieldRequiredMsg">Błędny adres email</span><span class="textfieldInvalidFormatMsg">Błędny adres e-mail</span></span></li>
              <li><span id="spryconfirm1">
                <label for="walidacjaemail">Podaj ponownie e-mail:</label>
                <input type="text" name="walidacjaemail" id="walidacjaemail" tabindex="3">
                <span class="confirmRequiredMsg">Pole wymagane</span><span class="confirmInvalidMsg">Adres się nie zgadza</span></span>
              </li>
              <li><span id="sprytextfield3">
              <label for="numertelefonu">Telefon:</label>
              <input type="text" name="numertelefonu" id="numertelefonu" tabindex="4">
              <span class="textfieldInvalidFormatMsg">Niewłaściwy numer</span><span class="textfieldMinCharsMsg">Niewłaściwy numer</span><span class="textfieldMinValueMsg">Za mało cyfr</span></span></li>
              <li>
                <label for="miasto">Miasto:</label>
                <input name="miasto" type="text" id="miasto" tabindex="5" maxlength="15">
              </li>
              <li>
              <span id="sprytextarea1">
              <label for="wiadomosc2">Wiadomość:</label>
              <textarea name="wiadomosc" id="wiadomosc2" cols="45" rows="5" tabindex="6"></textarea>
              <span class="textareaRequiredMsg">Pole wymagane</span><span class="textareaMinCharsMsg">Za mało znaków</span></span></li>
             
<li>
              
              <input type="submit" name="wyslij" id="wyslij" value="Wyślij" tabindex="6">
            </fieldset>
	  </form>
	  </li>
  		 </ul>
              
    
  
 
	  </div>


second file: jak_kupic.html (I paste only form's DIV)

<div class="form">
	  <form action="#" method="post" name="form1" id="form1">
            <fieldset>
              <legend>Formularz kontaktowy</legend>
              <li><span id="sprytextfield1">
              <label for="imieinazwisko">Imię i Nazwisko:</label>
              <input name="imieinazwisko" type="text" id="imieinazwisko" tabindex="1" maxlength="30">
              <span class="textfieldRequiredMsg">Pole wymagane</span><span class="textfieldMinCharsMsg">Za mało znaków</span></span></li>
              <li><span id="sprytextfield2">
              <label for="adresemail2">Adres e-mail:</label>
              <input type="text" name="adresemail" id="adresemail2" tabindex="2">
              <span class="textfieldRequiredMsg">Błędny adres email</span><span class="textfieldInvalidFormatMsg">Błędny adres e-mail</span></span></li>
              <li><span id="spryconfirm1">
                <label for="walidacjaemail">Podaj ponownie e-mail:</label>
                <input type="text" name="walidacjaemail" id="walidacjaemail" tabindex="3">
                <span class="confirmRequiredMsg">Pole wymagane</span><span class="confirmInvalidMsg">Adres się nie zgadza</span></span>
              </li>
              <li><span id="sprytextfield3">
              <label for="numertelefonu">Telefon:</label>
              <input type="text" name="numertelefonu" id="numertelefonu" tabindex="4">
              <span class="textfieldInvalidFormatMsg">Niewłaściwy numer</span><span class="textfieldMinCharsMsg">Niewłaściwy numer</span><span class="textfieldMinValueMsg">Za mało cyfr</span></span></li>
              <li>
                <label for="miasto">Miasto:</label>
                <input name="miasto" type="text" id="miasto" tabindex="5" maxlength="15">
              </li>
              <li>
              <span id="sprytextarea1">
              <label for="wiadomosc2">Wiadomość:</label>
              <textarea name="wiadomosc" id="wiadomosc2" cols="45" rows="5" tabindex="6"></textarea>
              <span class="textareaRequiredMsg">Pole wymagane</span><span class="textareaMinCharsMsg">Za mało znaków</span></span></li>
             
<li>
              
              <input type="submit" name="wyslij" id="wyslij" value="Wyślij" tabindex="6">
            </fieldset>
	  </form>
	  </li>
  		 </ul>
</div>


third file: jak_kupic.php (pasted only form's DIV)

<div class="form_field">
 	 <img src="images/jak_zamawiac_02.jpg" width="1024" height="661" alt="formularz">
  <?
  
  if(isset($_POST["sender"]))
  {
	  
  $imie=$_POST['imieinazwisko'];
  $email=$_POST['adresemail'];
  $telefon=$_POST['telefon'];
  $miasto=$_POST['miasto'];
  $wiadomosc=$_POST['wiadomosc'];
  
  //Potwierdzenie dla użytkownika
  $reply_subject= 'Zapytanie ze strony Hogar';
  $reply_body = 'Witamy serdecznie,\nOtrzymaliśmy Państwa wiadomość. Odezwiemy się najprędzej jak to mozliwe.\n\nZ poważaniem\nBiokominki Hogar';
  $reply_email = 'biuro@hogar-biokominki.pl';
  
  //Wysyłanie do Hogar
  $to = 'biuro@hogar-biokominki.pl';
  $from = $imie . "<" . $email .">";
  $subject = 'Zapytanie ze strony Hogar';
  $body="\n\nImię i Nazwisko" . $imie . "\n\nEmail: " . $email . "\n\nTelefon" . $telefon . "\n\nMiasto" . $miasto . "\n\nWiadomość:" . $wiadomosc;
  $coding = "Content-Type: text/plain; charse=utf-8 \nContent-Transfer-Encoding: 8bit";
  
  if(mail($to, $subject, $body, "From: " . $from . "\n"  . $coding))
  {
	  if(mail($email, $reply_subject, $reply_body, "From: " . $reply_email . "\n" . $coding))
	  {
		  echo"<p class=\"dziekujemy\"> Dziekujemy za wysłanie wiadomości!</p>";
	  }
	  else
	  {
    	   echo"<p class=\"dziekujemy\">Formularz nie został wysłany. Spróbuj ponownie.</p>";
	  }
  }
  }
  require_once("formularz.php");
  ?>
  
  		
  
  </div>


Looking forward to hearing from you guys!

kukula
Newbie Poster
22 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

Shouldn't the form's action attribute point to your PHP file ?

pritaeas
Posting Expert
Moderator
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

1) open formularz.php in line number 2 set action to jak_kupic.php

<form action="jak_kupic.php" method="post" id="form1">


save formularz.php and upload on server


2)DO NOT open jak_kupic.html. now open
www.hogar-biokominki.pl/formularz.php

urtrivedi
Nearly a Posting Virtuoso
1,306 posts since Dec 2008
Reputation Points: 257
Solved Threads: 270
 

I have changed "form action". Uploaded it to the server. Link /.formularz.php looks like my grandmother's teeth, and in /jak_kupic.html still nothings changed.
BUT!
Strange situation is when you send a form from /jak_kupic.php it works fine. But the layout is not looking good :/
What now should I change?

kukula
Newbie Poster
22 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 
dineshsjce
Newbie Poster
4 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

Did you set up your SMPT for the email so it knows how to send it?
smpt:
smpt_port:

fobos
Posting Whiz in Training
297 posts since Feb 2009
Reputation Points: 29
Solved Threads: 52
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: