Jump to content

FormToEmail not reading any values from table form, <h> </h> in table


PrPrO

Recommended Posts

Hello,

 

so this post is two flies in one go :D

 

First I will start with the form. I have another form which is not in table and it works fine, it reads all the values and send the email normally. Here is the code:

<form id="Contact Form" name="Contact Form" method="post" action="index.php?option=com_content&view=featured&Itemid=534'">
	 <p><br />
							 Odaberite proizvod:<br />
							 <select name="select" id="select">
							 <option value="Molimo odaberite" selected="selected">Molimo odaberite</option>
							 <option value="Karbonske cijevi">Karbonske cijevi </option>
							 <option value="Karbonski kepovi">Karbonski kepovi</option>
							 <option value="Kabine">Kabine</option>
							 <option value="Karbonski nosači za komande">Karbonski nosači za komande</option>
							 <option value="Karbonski D-Box">Karbonski D-Box</option>
							 <option value="Karbonske ploče raznih dimenzija">Karbonske ploče raznih dimenzija</option>
							 </select>
	 </p>
	 <p>Vaše ime:
	 <label>
		 <br />
		 <input type="text" name="ime" id="ime" />
		 </label>
	 </p>
	 <p>
	 <label>E-mail adresa: </label>
	 <label><br />
	 </label>
	 <label>
		 <input type="text" name="email" id="email" />
		 </label>
	 </p>
	 <p>Naslov:
	 <label>
		 <br />
		 <input type="text" name="naslov" id="naslov" />
		 </label>
	 </p>
	 <p>Unesite svoju poruku:<br />
	 <label>
		 <textarea name="poruka" id="poruka" cols="45" rows="5"></textarea>
		 </label>
	 </p>

	 <p>
	 <input name="newsletter" type="checkbox" id="newsletter" value="Želim primati newsletter" onclick="changeCheckboxText(
function changeCheckboxText(checkbox)
{
if (checkbox.checked)
checkbox.nextSibling.innerHTML = 'Želim primati newsletter';
else
checkbox.nextSibling.innerHTML = 'Ne želim primati newsletter;
}
;"/>
	 Označite ovaj kvadratić ako želite primati newsletter</p>
	 <p> </p>
	 <p>
	 <input type="submit" value="Pošalji Upit" />
		 <br />
	 </p>
 </form>

And the .php

<?php
if(isset($_POST['email'])) {

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "info@clm-pro-tk";
$email_subject = "Your email subject line";


function died($error) {
 // your error code can go here
	 echo "Ispričavamo se, prilikom slanja Vašeg upita pronašli smo pogrešku/e. ";
 echo "Pogreška/e će biti prikazane ispod.<br /><br />";
 echo $error."<br /><br />";
 echo "Molimo, vratite se na prijašnju stranicu i promjenite upit.<br /><br />";
 die();
}

// validation expected data exists
if(!isset($_POST['ime']) ||
 !isset($_POST['email']) ||
 !isset($_POST['naslov']) ||
 !isset($_POST['select']) ||
 !isset($_POST['poruka'])) {
 died('Ispričavamo se, pronašli smo pogrešku prilikom slanja vašeg upita.');	
}

$ime = $_POST['ime']; // required
$email = $_POST['email']; // required
$naslov = $_POST['naslov']; // required
$poruka = $_POST['poruka']; // required
$select = $_POST['select'] ; // required
$newsletter = $_POST['newsletter']; // not required
if($select == 'Molimo odaberite'){
died('Molimo Vas, odaberite proizvod.');
}
}
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email)) {
$error_message .= 'Vaš E-mail nije valjan.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$ime)) {
$error_message .= 'Vaše se ime sastoji od nepodržavanih znakova.<br />';
}
if(strlen($naslov) < 2) {
$error_message .= 'Vaš naslov nije valjan.<br />';

}
if(strlen($poruka) < 2) {
$error_message .= 'Vaša poruka je prekratka.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Detalji upita.\n\n";

function clean_string($string) {
 $bad = array("content-type","bcc:","to:","cc:","href");
 return str_replace($bad,"",$string);
}

$email_message .= "Ime: ".clean_string($ime)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
$email_message .= "Naslov: ".clean_string($naslov)."\n";
$email_message .= "Poruka: ".clean_string($poruka)."\n";

// create email headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
@ mail("info@clm-pro.tk", $naslov,
$poruka, "From:" . $email . "\r\n" . $newsletter . "\r\n" . $select . "\r\n" . $ime);

//AUTO RESPONCE MESSAGE
//Create main headers
$pporuka = "";
$pporuka .= "Poštovani ";
$pporuka .= $ime;
$pporuka .= ", hvala na Vašem upitu u vezi proizvoda ";
$pporuka .= $select;
$pporuka .= ", javit ćemo Vam se u što kraćem roku. ";
$pporuka .= "
Upitali ste nas slijedece: ";
$pporuka .= $poruka;
//E-mails subject
//Send the email
mail($email, $naslov, $pporuka, "From:" . "info@clm-pro.tk");
?>
Primili smo Vaš upit. Kontaktirat ćemo Vas u što kraćem roku

And this form is working great.

And now the one that isn't working... Here is the link to that form: http://www.clm-pro.t.../usluge-rezanja

Onpage code:

<p>(Forma će biti dovršena kroz par dana. Zahvaljujemo na strpljenju.)</p>
<form id="Contact Form" name="Contact Form" method="post" action="index.php?option=com_content&view=featured&Itemid=527">
<p>
<table>
<tbody>
<tr>
<td>             Sekcija 1       </td>
<td>                  </td>
<td>                                  Sekcija 2  </td>
<td>             </td>
</tr>
<tr>
<td>Profil u korijenu:</td>
<td><input name="puk1" id="puk1" size="6" maxlength="5" type="text" /></td>
<td>                        Profil u korijenu:</td>
<td><input name="puk2" id="puk2" size="6" maxlength="5" type="text" /></td>
</tr>
<tr>
<td>Dimenzija u korijenu:</td>
<td><input name="duk1" id="duk1" size="6" maxlength="5" type="text" /></td>
<td>               Dimenzija u korijenu:</td>
<td><input name="duk2" id="duk2" size="6" maxlength="5" type="text" /></td>
</tr>
<tr>
<td> Profil na vrhu:</td>
<td><input name="pnv1" id="pnv1" size="6" maxlength="5" type="text" /></td>
<td>                             Profil na vrhu:</td>
<td><input name="pnv2" id="pnv2" size="6" maxlength="5" type="text" /></td>
</tr>
<tr>
<td> Dimenzija na vrhu:</td>
<td><input name="dnv1" id="dnv1" size="6" maxlength="5" type="text" /></td>
<td>                    Dimenzija na vrhu:</td>
<td><input name="dnv2" id="dnv2" size="6" maxlength="5" type="text" /></td>
</tr>
<tr>
<td> Dužina panela:</td>
<td><input name="dp1" id="dp1" size="6" maxlength="5" type="text" /></td>
<td>                          Dužina panela:</td>
<td><input name="dp2" id="dp2" size="6" maxlength="5" type="text" /></td>
</tr>
<tr>
<td> Sweep:</td>
<td><input name="sw1" id="sw1" size="6" maxlength="5" type="text" /></td>
<td>                                       Sweep:</td>
<td><input name="sw2" id="sw2" size="6" maxlength="5" type="text" /></td>
</tr>
<tr>
<td> Zakrivljenost:</td>
<td><input name="zak1" id="zak1" size="6" maxlength="5" type="text" /></td>
<td>                             Zakrivljenost:</td>
<td><input name="zak2" id="zak2" size="6" maxlength="5" type="text" /></td>
</tr>
<tr>
<td>  </td>
<td>  </td>
<td>  </td>
<td>  </td>
</tr>
<tr>
<td> Sekcija 3</td>
<td></td>
<td>                                  Sekcija 4</td>
<td></td>
</tr>
<tr>
<td> Profil u korijenu:</td>
<td><input name="puk3" id="puk3" size="6" maxlength="5" type="text" /></td>
<td>                        Profil u korijenu:</td>
<td><input name="puk4" id="puk4" size="6" maxlength="5" type="text" /></td>
</tr>
<tr>
<td> Dimenzija u korijenu:</td>
<td><input name="duk3" id="duk3" size="6" maxlength="5" type="text" /></td>
<td>               Dimenzija u korijenu:</td>
<td><input name="duk4" id="duk4" size="6" maxlength="5" type="text" /></td>
</tr>
<tr>
<td> Profil na vrhu:</td>
<td><input name="pnv3" id="pnv3" size="6" maxlength="5" type="text" /></td>
<td>                             Profil na vrhu:</td>
<td><input name="pnv4" id="pnv4" size="6" maxlength="5" type="text" /></td>
</tr>
<tr>
<td> Dimenzija na vrhu:</td>
<td><input name="dnv3" id="dnv3" size="6" maxlength="5" type="text" /></td>
<td>                    Dimenzija na vrhu:</td>
<td><input name="dnv4" id="dnv4" size="6" maxlength="5" type="text" /></td>
</tr>
<tr>
<td> Dužina panela:</td>
<td><input name="dp3" id="dp3" size="6" maxlength="5" type="text" /></td>
<td>                          Dužina panela:</td>
<td><input name="dp4" id="dp4" size="6" maxlength="5" type="text" /></td>
</tr>
<tr>
<td> Sweep:</td>
<td><input name="sw3" id="sw3" size="6" maxlength="5" type="text" /></td>
<td>                                        Sweep:</td>
<td><input name="sw4" id="sw4" size="6" maxlength="5" type="text" /></td>
</tr>
<tr>
<td>Zakrivljenost:</td>
<td><input name="zak3" id="zak3" size="6" maxlength="5" type="text" /></td>
<td>                              Zakrivljenost:</td>
<td><input name="zak4" id="zak4" size="6" maxlength="5" type="text" /></td>
</tr>
</tbody>
</table>
</p>
<p> </p>
<p> </p>
<p>
<table>
<tbody>
<tr>
<td>Ime:</td>
<td><input name="ime" id="ime" size="15" maxlength="25" type="text" /></td>
</tr>
<tr>
<td>E-Mail:</td>
<td><input name="email" id="email" size="15" maxlength="25" type="text" /></td>
</tr>
<tr>
<td>Adresa:</td>
<td><input name="adresa" id="adresa" size="15" maxlength="40" type="text" /></td>
</tr>
<tr>
<td>Država:</td>
<td><input name="drzava" id="drzava" size="15" maxlength="25" type="text" /></td>
</tr>
<tr>
<td>Poštanski broj:</td>
<td><input name="zip" id="zip" size="15" maxlength="25" type="text" /></td>
</tr>
<tr>
<td>Telefon:</td>
<td><input name="tel" id="tel" size="15" maxlength="25" type="text" /></td>
</tr>
<tr>
<td>Napomena:</td>
<td><textarea name="poruka" id="poruka" cols="45" rows="5"></textarea></td>
</tr>
</tbody>
</table>
</p>
<p><input value="Pošalji Upit" type="submit" /></p>
</form>

And the .php for that form:

<?php
if(isset($_POST['email'])) {

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "info@clm-pro-tk";
$email_subject = "Your email subject line";


function died($error) {
 // your error code can go here
	 echo "Ispričavamo se, prilikom slanja Vašeg upita pronašli smo pogrešku/e. ";
 echo "Pogreška/e će biti prikazane ispod.<br /><br />";
 echo $error."<br /><br />";
 echo "Molimo, vratite se na prijašnju stranicu i promjenite upit.<br /><br />";
 die();
}

// validation expected data exists
if(!isset($_POST['ime']) ||
!isset($_POST['email']) ||
!isset($_POST['adresa']) ||
!isset($_POST['drzava']) ||
!isset($_POST['zip']) ||
!isset($_POST['tel']) ||
!isset($_POST['poruka']) ||
!isset($_POST['puk1']) ||
 !isset($_POST['puk2']) ||
 !isset($_POST['puk3']) ||
 !isset($_POST['puk4']) ||
!isset($_POST['duk1']) ||
!isset($_POST['duk2']) ||
!isset($_POST['duk3']) ||
!isset($_POST['duk4']) ||
!isset($_POST['pnv1']) ||
!isset($_POST['pnv2']) ||
!isset($_POST['pnv3']) ||
!isset($_POST['pnv4']) ||
!isset($_POST['dnv1']) ||
!isset($_POST['dnv2']) ||
!isset($_POST['dnv3']) ||
!isset($_POST['dnv4']) ||
!isset($_POST['dp1']) ||
!isset($_POST['dp2']) ||
!isset($_POST['dp3']) ||
!isset($_POST['dp4']) ||
!isset($_POST['sw1']) ||
!isset($_POST['sw2']) ||
!isset($_POST['sw3']) ||
!isset($_POST['sw4']) ||
!isset($_POST['zak1']) ||
!isset($_POST['zak2']) ||
!isset($_POST['zak3']) ||
!isset($_POST['zak4'])) {
 died('Ispričavamo se, pronašli smo pogrešku prilikom slanja vašeg upita.');	
}
}
$email_message .= "Ime: " . $_POST['ime'] . "\n";
$email_message .= "E-Mail: " . $_POST['email'] . "\n";
$email_message .= "Adresa: " . $_POST['adresa'] . "\n";
$email_message .= "Država: " . $_POST['drzava'] . "\n";
$email_message .= "Poštanski broj: " . $_POST['zip'] . "\n";
$email_message .= "Telefon: " . $_POST['tel'] . "\n";
$email_message .= "Poruka: " . $_POST['poruka'] . "\n";
$email_message .= "Profil u korijenu(1): " . $_POST['puk1'] . "\n";
$email_message .= "Profil u korijenu(2): " . $_POST['puk2'] . "\n";
$email_message .= "Profil u korijenu(3): " . $_POST['puk3'] . "\n";
$email_message .= "Profil u korijenu(4): " . $_POST['puk4'] . "\n";
$email_message .= "Dimenzija u korijenu(1): " . $_POST['duk1'] . "\n";
$email_message .= "Dimenzija u korijenu(2): " . $_POST['duk2'] . "\n";
$email_message .= "Dimenzija u korijenu(3): " . $_POST['duk3'] . "\n";
$email_message .= "Dimenzija u korijenu(4): " . $_POST['duk4'] . "\n";
$email_message .= "Profil na vrhu(1): " . $_POST['pnv1'] . "\n";
$email_message .= "Profil na vrhu(2): " . $_POST['pnv2'] . "\n";
$email_message .= "Profil na vrhu(3): " . $_POST['pnv3'] . "\n";
$email_message .= "Profil na vrhu(4): " . $_POST['pnv4'] . "\n";
$email_message .= "Dimenzija na vrhu(1): " . $_POST['dnv1'] . "\n";
$email_message .= "Dimenzija na vrhu(2): " . $_POST['dnv2'] . "\n";
$email_message .= "Dimenzija na vrhu(3): " . $_POST['dnv3'] . "\n";
$email_message .= "Dimenzija na vrhu(4): " . $_POST['dnv4'] . "\n";
$email_message .= "Dužina panela (1): " . $_POST['dp1'] . "\n";
$email_message .= "Dužina panela (2): " . $_POST['dp2'] . "\n";
$email_message .= "Dužina panela (3): " . $_POST['dp3'] . "\n";
$email_message .= "Dužina panela (4): " . $_POST['dp4'] . "\n";
$email_message .= "Sweep(1): " . $_POST['sw1'] . "\n";
$email_message .= "Sweep(2): " . $_POST['sw2'] . "\n";
$email_message .= "Sweep(3): " . $_POST['sw3'] . "\n";
$email_message .= "Sweep(4): " . $_POST['sw4'] . "\n";
$email_message .= "Zakrivljenost(1): " . $_POST['zak1'] . "\n";
$email_message .= "Zakrivljenost(2): " . $_POST['zak2'] . "\n";
$email_message .= "Zakrivljenost(3): " . $_POST['zak3'] . "\n";
$email_message .= "Zakrivljenost(4): " . $_POST['zak4'] . "\n";

// create email headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
@ mail("info@clm-pro.tk", $poruka, "From:" . $email . "\r\n" . $adresa . "\r\n" . $drzava . "\r\n" . $ime . "\r\n" . $zip . "\r\n" . $tel . "\r\n" . $puk1 . "\r\n" . $puk2 . "\r\n" . $puk3 . "\r\n" . $puk4 . "\r\n" . $duk1 . "\r\n" . $duk2 . "\r\n" . $duk3 . "\r\n" . $duk4 . "\r\n" . $pnv1 . "\r\n" . $pnv2 . "\r\n" . $pnv3 . "\r\n" . $pnv4 . "\r\n" . $dnv1 . "\r\n" . $dnv2 . "\r\n" . $dnv3 . "\r\n" . $dnv4 . "\r\n" . $dp1 . "\r\n" . $dp2 . "\r\n" . $dp3 . "\r\n" . $dp4 . "\r\n" . $sw1 . "\r\n" . $sw2 . "\r\n" . $sw3 . "\r\n" . $sw4 . "\r\n" . $zak1 . "\r\n" . $zak2 . "\r\n" . $zak3 . "\r\n" . $zak4);

//AUTO RESPONCE MESSAGE
//Create main headers
$pporuka = "";
$pporuka .= "Poštovani ";
$pporuka .= $ime;
$pporuka .= ", dimenzije koje ste nam poslali su slijedeće: ";
$pporuka .= ", Profil u korijenu(1): ";
$pporuka .= $puk1;
$pporuka .= ", Profil u korijenu(2): ";
$pporuka .= $puk2;
$pporuka .= ", Profil u korijenu(3): ";
$pporuka .= $puk3;
$pporuka .= ", Profil u korijenu(4): ";
$pporuka .= $puk4;
$pporuka .= ", Dimenzija u korijenu(1): ";
$pporuka .= $duk1;
$pporuka .= ", Dimenzija u korijenu(2): ";
$pporuka .= $duk2;
$pporuka .= ", Dimenzija u korijenu(3): ";
$pporuka .= $duk3;
$pporuka .= ", Dimenzija u korijenu(4): ";
$pporuka .= $duk4;
$pporuka .= "
Upitali ste nas slijedece: ";
$pporuka .= $poruka;
//E-mails subject
//Send the email
mail($email, $pporuka, "From:" . "info@clm-pro.tk");
?>

I don't know what to do anymore... I tried replacing the $_POST with $_GET in $email_message and inserting the clean.string but then i got error that i have to define it but I did :P

 

Can you please help me somehow?

 

And the other "problem"... when I set text style which is in table to heading 1, it increases the table height which wouldn't be big dea when there wouldn't be background for that table :P So, what I wan't to do is set normal height for the table. Here is the link(don't look at the images, it's just for test, webpage is curently under construction): http://www.clm-pro.t...i?view=featured

The problematic text is: "Karbonske cijevi"

 

Thank you in advance!

 

Matija

Link to comment
Share on other sites

There's too much of code, it's scarry. You should create some array and iterate each input field for generating form and for receive and parse data. Then you would avoid mistakes for sure.

Why don't you just check what's going on step by step. First try to print_r($_POST) and see what's there, then try to print e-mail message and check variables needed as parameters for your functions. I found one difference with mail function.

 

There's no $email variable available (BTW no $naslov in mail parameters), you keep it in $_POST['email'] only. So you're trying send mail to anybody.

Edited by BagoZonde
Link to comment
Share on other sites

tldr.

you only have to read the last code :P

If you want to help

 

EDIT: @BagoZonde, what do you mean there is no $email variable? It is red from the form. And about print_r, I tried and tried before to print it but without success, can you please copy the code I have to insert?

 

Thank you

Edited by PrPrO
Link to comment
Share on other sites

EDIT: @BagoZonde, what do you mean there is no $email variable? It is red from the form. And about print_r, I tried and tried before to print it but without success, can you please copy the code I have to insert?

 

Thank you

 

Are you sure? Have you checked $email variable before executing mail() function? Just insert

 

print 'E-MAIL: '.$email;

 

and see if there's something.

That same with creating $headers, there's nothing in $email.

 

Is it your code or you just modified one?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.