Jump to content


Photo

After Submiting, Formtoemail.php Return Error At Php Closure(?>)


  • Please log in to reply
10 replies to this topic

#1 PrPrO

PrPrO

    Member

  • Members
  • PipPip
  • 10 posts

Posted 31 December 2012 - 09:53 AM

Hello,

I have created a little bigger form to be sent to email after submiting but after I click submit(Pošalji) buton, i get the error: Parse error: syntax error, unexpected $end in /home/a7264383/public_html/tmp/htmlAvDbUi on line 129. This error appears when i submit on this 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['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']) ||
!isset($_POST['ime']) ||
!isset($_POST['email']) ||
!isset($_POST['adresa']) ||
!isset($_POST['drzava']) ||
!isset($_POST['zip']) ||
!isset($_POST['tel']) ||
!isset($_POST['poruka'])) {
	 died('Ispričavamo se, pronašli smo pogrešku prilikom slanja vašeg upita.');	

	
$email_message .= "Ime: ".clean_string($ime)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
$email_message .= "Adresa: ".clean_string($adresa)."\n";
$email_message .= "Drzava: ".clean_string($drzava)."\n";
$email_message .= "Poštanski broj: ".clean_string($zip)."\n";
$email_message .= "Telefon: ".clean_string($tel)."\n";
$email_message .= "Napomena: ".clean_string($poruka)."\n";
$email_message .= "Profil u korijenu(1): ".clean_string($puk1)."\n";
$email_message .= "Profil u korijenu(2): ".clean_string($puk2)."\n";
$email_message .= "Profil u korijenu(3): ".clean_string($puk3)."\n";
$email_message .= "Profil u korijenu(4): ".clean_string($puk4)."\n";
$email_message .= "Dimenzija u korijenu(1): ".clean_string($duk1)."\n";
$email_message .= "Dimenzija u korijenu(2): ".clean_string($duk2)."\n";
$email_message .= "Dimenzija u korijenu(3): ".clean_string($duk3)."\n";
$email_message .= "Dimenzija u korijenu(4): ".clean_string($duk4)."\n";
$email_message .= "Profil na vrhu(1): ".clean_string($pnv1)."\n";
$email_message .= "Profil na vrhu(2): ".clean_string($pnv2)."\n";
$email_message .= "Profil na vrhu(3): ".clean_string($pnv3)."\n";
$email_message .= "Profil na vrhu(4): ".clean_string($pnv4)."\n";
$email_message .= "Dimenzija na vrhu(1): ".clean_string($dnv1)."\n";
$email_message .= "Dimenzija na vrhu(2): ".clean_string($dnv2)."\n";
$email_message .= "Dimenzija na vrhu(3): ".clean_string($dnv3)."\n";
$email_message .= "Dimenzija na vrhu(4): ".clean_string($dnv4)."\n";
$email_message .= "Dužina panela (1): ".clean_string($dp1)."\n";
$email_message .= "Dužina panela (2): ".clean_string($dp2)."\n";
$email_message .= "Dužina panela (3): ".clean_string($dp3)."\n";
$email_message .= "Dužina panela (4): ".clean_string($dp4)."\n";
$email_message .= "Sweep(1): ".clean_string($sw1)."\n";
$email_message .= "Sweep(2): ".clean_string($sw2)."\n";
$email_message .= "Sweep(3): ".clean_string($sw3)."\n";
$email_message .= "Sweep(4): ".clean_string($sw4)."\n";
$email_message .= "Zakrivljenost(1): ".clean_string($zak1)."\n";
$email_message .= "Zakrivljenost(2): ".clean_string($zak2)."\n";
$email_message .= "Zakrivljenost(3): ".clean_string($zak3)."\n";
$email_message .= "Zakrivljenost(4): ".clean_string($zak4)."\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" . $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" . $dp . "\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" . $zak . "\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");
?>
line 127 is
mail($email, $pporuka, "From:" . "info@clm-pro.tk");

and when I delete the Auto-respose part, I get another error: Parse error: syntax error, unexpected $end in /home/a7264383/public_html/tmp/htmlaJcgAB on line 100. on following code:
<?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['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']) ||
!isset($_POST['ime']) ||
!isset($_POST['email']) ||
!isset($_POST['adresa']) ||
!isset($_POST['drzava']) ||
!isset($_POST['zip']) ||
!isset($_POST['tel']) ||
!isset($_POST['poruka'])) {
	 died('Ispričavamo se, pronašli smo pogrešku prilikom slanja vašeg upita.');	

	
$email_message .= "Ime: ".clean_string($ime)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
$email_message .= "Adresa: ".clean_string($adresa)."\n";
$email_message .= "Drzava: ".clean_string($drzava)."\n";
$email_message .= "Poštanski broj: ".clean_string($zip)."\n";
$email_message .= "Telefon: ".clean_string($tel)."\n";
$email_message .= "Napomena: ".clean_string($poruka)."\n";
$email_message .= "Profil u korijenu(1): ".clean_string($puk1)."\n";
$email_message .= "Profil u korijenu(2): ".clean_string($puk2)."\n";
$email_message .= "Profil u korijenu(3): ".clean_string($puk3)."\n";
$email_message .= "Profil u korijenu(4): ".clean_string($puk4)."\n";
$email_message .= "Dimenzija u korijenu(1): ".clean_string($duk1)."\n";
$email_message .= "Dimenzija u korijenu(2): ".clean_string($duk2)."\n";
$email_message .= "Dimenzija u korijenu(3): ".clean_string($duk3)."\n";
$email_message .= "Dimenzija u korijenu(4): ".clean_string($duk4)."\n";
$email_message .= "Profil na vrhu(1): ".clean_string($pnv1)."\n";
$email_message .= "Profil na vrhu(2): ".clean_string($pnv2)."\n";
$email_message .= "Profil na vrhu(3): ".clean_string($pnv3)."\n";
$email_message .= "Profil na vrhu(4): ".clean_string($pnv4)."\n";
$email_message .= "Dimenzija na vrhu(1): ".clean_string($dnv1)."\n";
$email_message .= "Dimenzija na vrhu(2): ".clean_string($dnv2)."\n";
$email_message .= "Dimenzija na vrhu(3): ".clean_string($dnv3)."\n";
$email_message .= "Dimenzija na vrhu(4): ".clean_string($dnv4)."\n";
$email_message .= "Dužina panela (1): ".clean_string($dp1)."\n";
$email_message .= "Dužina panela (2): ".clean_string($dp2)."\n";
$email_message .= "Dužina panela (3): ".clean_string($dp3)."\n";
$email_message .= "Dužina panela (4): ".clean_string($dp4)."\n";
$email_message .= "Sweep(1): ".clean_string($sw1)."\n";
$email_message .= "Sweep(2): ".clean_string($sw2)."\n";
$email_message .= "Sweep(3): ".clean_string($sw3)."\n";
$email_message .= "Sweep(4): ".clean_string($sw4)."\n";
$email_message .= "Zakrivljenost(1): ".clean_string($zak1)."\n";
$email_message .= "Zakrivljenost(2): ".clean_string($zak2)."\n";
$email_message .= "Zakrivljenost(3): ".clean_string($zak3)."\n";
$email_message .= "Zakrivljenost(4): ".clean_string($zak4)."\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" . $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" . $dp . "\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" . $zak . "\r\n" . $zak3 . "\r\n" . $zak4);
?>
line 100 is
$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" . $dp . "\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" . $zak . "\r\n" . $zak3 . "\r\n" . $zak4);
It doesn't mather if I change all that code to with(I still get the same error)
@mail($email_to, $email_subject, $email_message, $headers);

And I have very similar form to this one:
<?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" . $trup . "\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.

Are those error indicators and what is required and what si not neccesary?

Can you help me anyhow please?

Thank you in advance!

EDIT: Here is the link to the problematic form: http://www.clm-pro.t...ex.php/galerija it still isn't done...
And the link to working form: http://www.clm-pro.t...ured&Itemid=526

Edited by PrPrO, 31 December 2012 - 09:54 AM.


#2 Muddy_Funster

Muddy_Funster

    Advanced Member

  • Members
  • PipPipPip
  • 2,993 posts

Posted 31 December 2012 - 09:57 AM

you never close you if statment. you are missing a } out so the code is running out before it is properly terminated.
A simple password hash :

function makePass($word=''){
  $dbSalt = '$2a$07$'.substr(hash('whirlpool',$word),0,22);
  $dbPass = crypt($word, $dbSalt);
 return substr($dbPass,12);
}



My SQL/PHP Blog

#3 PrPrO

PrPrO

    Member

  • Members
  • PipPip
  • 10 posts

Posted 31 December 2012 - 10:57 AM

Thank you very much for your fast reply, I looked many times a couldnt find it :D I fixed this a some other minor problems but, here is the other one.. The forms you can see are in tables built in Joomla and it seems that the formtoemail.php doesn't read them, because i get error that my message is to short, or I get error on line 59 which is:

$email_message .= "Ime: ".clean_string($ime)."\n";

meaning that it is missing this information, meaning, it doesn't read the forms in tables?

#4 Muddy_Funster

Muddy_Funster

    Advanced Member

  • Members
  • PipPipPip
  • 2,993 posts

Posted 31 December 2012 - 11:14 AM

I know nothing about jumla, I hate it with a passion, try asking in the PHP applications section, should get a responce in there
A simple password hash :

function makePass($word=''){
  $dbSalt = '$2a$07$'.substr(hash('whirlpool',$word),0,22);
  $dbPass = crypt($word, $dbSalt);
 return substr($dbPass,12);
}



My SQL/PHP Blog

#5 PrPrO

PrPrO

    Member

  • Members
  • PipPip
  • 10 posts

Posted 31 December 2012 - 11:31 AM

It isn't about Joomla, it's about formtoemail.php not reading values from the tables :P

#6 Muddy_Funster

Muddy_Funster

    Advanced Member

  • Members
  • PipPipPip
  • 2,993 posts

Posted 31 December 2012 - 11:50 AM

which may well depend on how joomla rendres the information that it uses in it's tables. have you done a vardump of your $ime to see what's in there?
A simple password hash :

function makePass($word=''){
  $dbSalt = '$2a$07$'.substr(hash('whirlpool',$word),0,22);
  $dbPass = crypt($word, $dbSalt);
 return substr($dbPass,12);
}



My SQL/PHP Blog

#7 PrPrO

PrPrO

    Member

  • Members
  • PipPip
  • 10 posts

Posted 31 December 2012 - 11:55 AM

vardump using arrays? I didn't, can you help me how to?

#8 DavidAM

DavidAM

    Advanced Member

  • Gurus
  • 1,976 posts
  • LocationSpring, TX USA

Posted 01 January 2013 - 08:20 PM

The $ime variable does not exist. In fact, none of the variables that you pass to clean_string have been defined. It would appear that your script expects register_globals to be on, which is a BAD thing. This setting has been deprecated for some time. It is a security issue. To access the fields from your form, you need to refer to the $_POST array. You have tested for them at the beginning of the script, you need to use them in the same way:

$email_message .= "Ime: " . clean_string($_POST['ime']) . "\n";
-- I haven't lost my mind, it's backed up on tape ... somewhere!

#9 PrPrO

PrPrO

    Member

  • Members
  • PipPip
  • 10 posts

Posted 02 January 2013 - 07:15 AM

Thank you very much for your reply, I replaced the code to what you said and I got the following error: Fatal error: Call to undefined function clean_string() in /home/a7264383/public_html/tmp/htmliJLCfz on line 59
line 59 is
$email_message .= "Ime: " . clean_string($_POST['ime']) . "\n";
The clean_string has to be defined
EDIT: I've tried to define the clean_string but I dont get anything in mail subject or body and the email it was sent from :P

Edited by PrPrO, 02 January 2013 - 07:27 AM.


#10 DavidAM

DavidAM

    Advanced Member

  • Gurus
  • 1,976 posts
  • LocationSpring, TX USA

Posted 02 January 2013 - 05:47 PM

"clean_string" is NOT a PHP (built-in) function. You were calling it in your original code that you posted. It is probably defined in some file that you need to include. I don't see any include statements in your posted code, I figured the include statements were in some part of the code that you did not post.
-- I haven't lost my mind, it's backed up on tape ... somewhere!

#11 PrPrO

PrPrO

    Member

  • Members
  • PipPip
  • 10 posts

Posted 03 January 2013 - 08:03 AM

Yes, but I have to define it somehow. And this is the main file, that ones has to get values and send them...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com