We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,417 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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!

5
Contributors
5
Replies
3 Weeks
Discussion Span
1 Year Ago
Last Updated
6
Views
kukula
Light Poster
25 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

pritaeas
Posting Prodigy
Moderator
9,315 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,467
Skill Endorsements: 86

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
Posting Virtuoso
1,715 posts since Dec 2008
Reputation Points: 299
Solved Threads: 362
Skill Endorsements: 24

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
Light Poster
25 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
dineshsjce
Newbie Poster
4 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

fobos
Posting Whiz
345 posts since Feb 2009
Reputation Points: 29
Solved Threads: 67
Skill Endorsements: 3

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0860 seconds using 2.77MB