Echo is not displayed

What’s wrong there? The echo it isn’t showed.

[php]<?php

$name = $_POST['Nume'];
$phone = $_POST['Telefon'];
$email = $_POST['Email'];
$subject = $_POST['Subiect'];
$message = $_POST['Mesaj'];
$formcontent = "*De la: $name \n *Telefon: $phone \n *Email: $email \n *Mesaj: $message";
						
if($name !='' && $email !='' && $subject !='' && $message !=''){
(mail('[email protected]', $subject, $formcontent);
							
echo "Mesaj trimis!";
}
else{
echo "Trebuie sa completezi toate campurile cu *";
}

?>[/php]

Which echo statement you have 2?

Enable display_errors or error_logging or check your error logs.

You have an error

You have a fatal php parse/syntax error on line 11 and your code is not running at all.

You need to set php’s error_reporting to E_ALL and display_errors to ON, in the php.ini on your development system (you cannot put these settings into your code and have them work for this type of error since your code doesn’t run) so that php will help you when learning, developing, and debugging code.

Change:

(mail('[email protected]', $subject, $formcontent );

To:

(mail('[email protected]', $subject, $formcontent) );

Missing closing bracket… “)

Also see the PHP documentation for displaying errors.

PkraM, the function does not need to be wrapped in parentheses. Adding the missing one does not make it better, when the first part shouldn’t be there.

lol - True! ;D Just working with what was there…

Try:

[code]$name = $_POST[‘Nume’];

$phone = $_POST[‘Telefon’];

$email = $_POST[‘Email’];

$subject = $_POST[‘Subiect’];

$message = $_POST[‘Mesaj’];

$formcontent = “*De la: $name \n *Telefon: $phone \n *Email: $email \n *Mesaj: $message”;

if($name !=’’ && $email !=’’ && $subject !=’’ && $message !=’’) {

if( mail('[email protected]', $subject, $formcontent ) ) {
   
echo "Mesaj trimis!";

}
else{

echo "Trebuie sa completezi toate campurile cu *";

}

}[/code]

[member=88301]PkraM[/member],

Posting ‘fixed’ code or code to try, without including an explanation of what was fixed or why to do something differently, is not helpful. It doesn’t teach anything.

You have also incorrectly altered the OP’s program logic, so that the - “You must fill in all fields…” output will be displayed when the mail() call fails, not when one or more of the form field values are empty. Wouldn’t a message indicating that the email could not be sent (and logging the actual error information being returned to php) be the ‘fixed’ logic?

If you are serious about helping, take the time to post things that add to the thread you are posting in.

Sponsor our Newsletter | Privacy Policy | Terms of Service