Implemented php script to send e-mail

Implemented php script to send e-mail

am 07.09.2007 09:14:44 von Mauro Sacchetto

I have to create a form to send mail in a wep page.
SO, I'm trying to implement the php script in html code.
This solution has a trouble:

============================================================ ==========
" ?>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> xmlns="http://www.w3.org/1999/xhtml">




B&B «LA LOCANDA DI RE MANFREDI» - PALAZZO SAN<br /> GERVASIO (PZ)








È possibile inviarci una comunicazione direttamente da questo
form


Riempire i campi richiesti e premere il pulsante "Invia"






if (isset($_POST['action']) && ($_POST['action']=='invia')) {
$receiverMail = "samiel@netsons.org";
$name = ltrim(rtrim(strip_tags(stripslashes($_POST['name']))));
$email = ltrim(rtrim(strip_tags(stripslashes($_POST['email']))));
$subject = ltrim(rtrim(strip_tags(stripslashes($_POST['subject']))));
$msg = ltrim(rtrim(strip_tags($_POST['msg'])));
$ip = getenv("REMOTE_ADDR");
$msgformat = "Messaggio da: $name ($ip)\nEmail: $email\n\n$msg";
if(empty($name) || empty($email) || empty($subject) || empty($msg)) {
echo "

Il messaggio non e' stato inviato


Si prega di compilare tutti i campi }
elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z 0-9-]+)*(\.[a-z
{2,3})$", $email)) {
echo "

Il messaggio non e' stato inviato


L'indirizzo e-mail indicato non e' valido

";
}
else {
mail($receiverMail, $subject, $msgformat, "From: $name <$email>");
echo "

Il messaggio e' stato inviato correttamente


Risponderemo il piu' presto possibile


Grazie di averci scritto

"; }
}
?>

Nome:







Indirizzo e-mail:







Oggetto:







Messaggio:








           




============================================================ ==========

Infact, after sending the email, I don't read the message:
"The e-mail was sent correcty" etc, but I continue to see
the form... Where is my misteke?

Thanx!
MS

Re: Implemented php script to send e-mail

am 07.09.2007 11:11:56 von Courtney

Mauro Sacchetto wrote:
> I have to create a form to send mail in a wep page.
> SO, I'm trying to implement the php script in html code.
> This solution has a trouble:
>
> ============================================================ ==========
?>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> xmlns="http://www.w3.org/1999/xhtml">




B&B «LA LOCANDA DI RE MANFREDI» - PALAZZO SAN<br /> GERVASIO (PZ)








È possibile inviarci una comunicazione direttamente da questo
form


Riempire i campi richiesti e premere il pulsante "Invia"






if (isset($_POST['action']) && ($_POST['action']=='invia')) {
$receiverMail = "samiel@netsons.org";
$name = ltrim(rtrim(strip_tags(stripslashes($_POST['name']))));
$email = ltrim(rtrim(strip_tags(stripslashes($_POST['email']))));
$subject = ltrim(rtrim(strip_tags(stripslashes($_POST['subject']))));
$msg = ltrim(rtrim(strip_tags($_POST['msg'])));
$ip = getenv("REMOTE_ADDR");
$msgformat = "Messaggio da: $name ($ip)\nEmail: $email\n\n$msg";
if(empty($name) || empty($email) || empty($subject) || empty($msg)) {
echo "

Il messaggio non e' stato inviato


Si prega di compilare tutti i campi ?>

Nome:







Indirizzo e-mail:







Oggetto:







Messaggio:








           


}

elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z 0-9-]+)*(\.[a-z
{2,3})$", $email)) {
echo "

Il messaggio non e' stato inviato


L'indirizzo e-mail indicato non e' valido

";
?>

Nome:


echo $name.




Indirizzo e-mail:







Oggetto:


?> echo $message;




>        
   


}
else {
mail($receiverMail, $subject, $msgformat, "From: $name <$email>");
echo "

Il messaggio e' stato inviato correttamente


Risponderemo il piu' presto possibile


Grazie di averci scritto

"; }

}
?>



study the amendments..

Re: Implemented php script to send e-mail

am 07.09.2007 13:50:55 von Macca

>$name = ltrim(rtrim(strip_tags(stripslashes($_POST['name']))));
>$email = ltrim(rtrim(strip_tags(stripslashes($_POST['email']))));
>$subject = ltrim(rtrim(strip_tags(stripslashes($_POST['subject']))));
>$msg = ltrim(rtrim(strip_tags($_POST['msg'])));



Not really an answer to your question, just a tip. You shouldnt repeat
code like this really,plus you dont need left trim and right trim
seperately, just call trim() which will do doth.

create a "sanitize" function:



function sanitize($dirty_data)(

$clean_data = trim(strip_tags(stripslashes($dirty_Data)));

return $clean_data;
}


Then:

$name = sanitize($_POST['name']);
$email = sanitize($_POST['email']);
$subject = sanitize($_POST['subject']);
$msg = sanitize($_POST['msg']);


Makes you code clearer and you can then re-use the function in any of
your applications then.

Re: Implemented php script to send e-mail

am 07.09.2007 14:08:40 von Captain Paralytic

Well I can't see what TNP's done, but I don't see where you expect
$_POST['actio'] to get the value 'invia' assigned to it.

Re: Implemented php script to send e-mail

am 07.09.2007 14:53:56 von Mauro Sacchetto

The Natural Philosopher wrote:
[cut]
> study the amendments..

I tried to cut&past your code, but thep age doesn't open
with this error message:

=====================================================
Parse error: syntax error, unexpected T_VARIABLE
in /var/www/netsons.org/samiel/form.php on line 38
=====================================================

Thanx
MS

Re: Implemented php script to send e-mail

am 07.09.2007 15:06:46 von Mauro Sacchetto

Captain Paralytic wrote:
> Well I can't see what TNP's done, but I don't see where you expect
> $_POST['actio'] to get the value 'invia' assigned to it.

Isn't it the function assigned
to "Invia" button?

M.

Re: Implemented php script to send e-mail

am 07.09.2007 15:15:27 von Mauro Sacchetto

macca wrote:
> Not really an answer to your question, just a tip. You shouldnt repeat
> code like this really,plus you dont need left trim and right trim
> seperately, just call trim() which will do doth.

When the script will work, I'll try
your better solution...
Thanx
M.

Re: Implemented php script to send e-mail

am 07.09.2007 15:31:51 von luiheidsgoeroe

On Fri, 07 Sep 2007 15:06:46 +0200, Mauro Sacchetto
wrote:

> Captain Paralytic wrote:
>> Well I can't see what TNP's done, but I don't see where you expect
>> $_POST['actio'] to get the value 'invia' assigned to it.
>
> Isn't it the function assigned
> to "Invia" button?

It's assigned to a button allright, but give that button the name 'action'
:)
--
Rik Wasmus

Re: Implemented php script to send e-mail

am 07.09.2007 15:41:03 von Captain Paralytic

On 7 Sep, 14:06, Mauro Sacchetto wrote:
> Captain Paralytic wrote:
> > Well I can't see what TNP's done, but I don't see where you expect
> > $_POST['actio'] to get the value 'invia' assigned to it.
>
> Isn't it the function assigned
> to "Invia" button?
>
> M.

Even if the button was named "action" (which it isn't), the value you
have assigned is "Invia", but you are testing for 'invia'!

Re: Implemented php script to send e-mail

am 07.09.2007 17:08:05 von Mauro Sacchetto

Rik Wasmus wrote:
>> Isn't it the function assigned
>> to "Invia" button?
>
> It's assigned to a button allright, but give that button the name 'action'

Well, I'm studying in this period html and css,
and, to be honest - but it's very easy to understand
considering my troubles with php, I've no notion
about it. So... actually no idea about the way
to accomplish this goal "give that button
the name 'action'"... :-(

M.

Re: Implemented php script to send e-mail

am 07.09.2007 17:16:01 von Mauro Sacchetto

Captain Paralytic wrote:
> Even if the button was named "action" (which it isn't), the value you
> have assigned is "Invia", but you are testing for 'invia'!

Ok, but what about the syntax error
I refer in my previous post?
It's such that I cannot open the page...

M.

Re: Implemented php script to send e-mail

am 07.09.2007 17:17:14 von luiheidsgoeroe

On Fri, 07 Sep 2007 17:08:05 +0200, Mauro Sacchetto =

wrote:

> Rik Wasmus wrote:
>>> Isn't it the function assigned
>>> to "Invia" button?
>>
>> It's assigned to a button allright, but give that button the name =

>> 'action'
>
> Well, I'm studying in this period html and css,
> and, to be honest - but it's very easy to understand
> considering my troubles with php, I've no notion
> about it. So... actually no idea about the way
> to accomplish this goal "give that button
> the name 'action'"... :-(



But a little but more basic HTML knowledge would certainly benefit your =
=

ability to create scripts like these.
-- =

Rik Wasmus

Re: Implemented php script to send e-mail

am 07.09.2007 18:14:18 von Mauro Sacchetto

Rik Wasmus wrote:
> But a little but more basic HTML knowledge would certainly benefit your
> ability to create scripts like these.

You're absolutely right, just bought a manual!
Only, there are only 24 hours on a day... :-)

M.

Re: Implemented php script to send e-mail

am 07.09.2007 21:13:43 von Mauro Sacchetto

Rik Wasmus wrote:
> But a little but more basic HTML knowledge would certainly benefit your
> ability to create scripts like these.

I'm very confused by all these versions...
The last one, always not working, is the following one:




?>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> xmlns="http://www.w3.org/1999/xhtml">




B&B «LA LOCANDA DI RE MANFREDI» - PALAZZO SAN GERVASIO<br /> (PZ)









È possibile inviarci una comunicazione direttamente da questo
form


Riempire i campi richiesti e premere il pulsante "Invia"







if (isset($_POST['action']) && ($_POST['action']=='invia')) {
$receiverMail = "samiel@netsons.org";
$name = ltrim(rtrim(strip_tags(stripslashes($_POST['name']))));
$email = ltrim(rtrim(strip_tags(stripslashes($_POST['email']))));
$subject = ltrim(rtrim(strip_tags(stripslashes($_POST['subject']))));
$msg = ltrim(rtrim(strip_tags($_POST['msg'])));
$ip = getenv("REMOTE_ADDR");
$msgformat = "Messaggio da: $name ($ip)\nEmail: $email\n\n$msg";
if(empty($name) || empty($email) || empty($subject) || empty($msg)) {
echo "

Il messaggio non e' stato inviato


Si prega di compilare tutti i campi ?>

Nome:







Indirizzo e-mail:







Oggetto:







Messaggio:








           


}

elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z 0-9-]+)*(\.[a-z
{2,3})$", $email)) {
echo "

Il messaggio non e' stato inviato


L'indirizzo e-mail indicato non e' valido

";
?>

Nome:


echo $name.




Indirizzo e-mail:







Oggetto:


?> echo $message;




>        
   


}
else {
mail($receiverMail, $subject, $msgformat, "From: $name <$email>");
echo "

Il messaggio e' stato inviato correttamente


Risponderemo il piu' presto possibile


Grazie di averci scritto

"; }

}
?>




IS someone able to find the mistake?
Thanx!!!!!!!!!!!!!!

M.

Re: Implemented php script to send e-mail

am 08.09.2007 01:30:37 von Courtney

Mauro Sacchetto wrote:
> The Natural Philosopher wrote:
> [cut]
>> study the amendments..
>
> I tried to cut&past your code, but thep age doesn't open
> with this error message:
>
> =====================================================
> Parse error: syntax error, unexpected T_VARIABLE
> in /var/www/netsons.org/samiel/form.php on line 38
> =====================================================
>

well I get those every time I code.,

Get your thinking cap on.

Not going write it ALL for you..

> Thanx
> MS
>