Jose:
PHP 4.1 and higher have globals off as a security measure. You can google and read about that. A work around is to bind a variable with the value you receive from the posts. So...
If your form (in HTML) looks like:
<form name="contact" action="script.php" method="POST">Then you can call ALL data submitted in that form in one of two ways:
Using the POST Method:If data is POSTed to a website, it is sent without the users knowledge, or visibility. i.e. you will NOT get a url of
http://www.domain.com/index.php?var=Skeyn38n1l396ngl3891nl193n4.39n`.3895n92Rather, you will get a regular url, and all the data is passed in the header in an array.
Using the GET Method:If data is posted to a script via the GET method, then all value=data pairs will be visible via the URL. i.e.
http://www.domain.com/index.php?var=Skeyn38n1l396ngl3891nl193n4.39n`.3895n92This causes security problems for logins and makes things messy.
So once the user submits the form, it will go to script.php. This script will then send an email to the specified users.
So your email script as you show it is:
<?<br>$ToEmail = "somebody@somesite.com" . ", " ;<br>$ToEmail .= "another@somesite.com";<br>$ToSubject = "Contact";<br>$EmailBody = "Sent by: $FirstName\nEmail: $Email\nCompany: $Company\nTelephone: $Telefono\n\nMessage:\n$ToComments\n\n";<br>$EmailFooter="\nThis email was sent by: $FirstName from $REMOTE_ADDR If you feel that you recieved this e-mail by accident please contact us at www.somesite.com";<br>$Message = $EmailBody.$EmailFooter;<br>mail($ToEmail,$ToSubject, $Message);<br><br>Print "_root.EmailStatus=Complete.";<br>?>Well, to start things off, you need to specifiy a From person, otherwise you will get "Apache". So let's add this at the beginning:
<?<br>/* Get all info sent via form */<br>$firstname = $_POST['FirstName'];<br>$email = $_POST['Email'];<br>$company = $_POST['Company'];<br>$telnum = $_POST['Telefono'];<br>$comments = $_POST['ToComments'];<br><br>/* Specify the From */<br>$from = $firstname." <".$email.">";<br><br>/* Specify other headers */<br>$ToEmail = "somebody@somesite.com, " ;<br>$ToEmail .= "another@somesite.com";<br>$ToSubject = "Contact";<br><br>/* Write the body, footer, message of the Email */<br>$EmailBody = "Sent by: $firstname\nEmail: $dmail\nCompany: $company\nTelephone: $telnum\n\nMessage:\n$comments\n\n";<br><br>$EmailFooter="\nThis email was sent by: $firstname from $_SERVER['REMOTE_ADDR'] If you feel that you recieved this e-mail by accident please contact us at www.somesite.com";<br><br>$Message = $EmailBody.$EmailFooter;<br><br>/* Mail the message<br>mail() function takes the following form:<br> mail("To Email", "Subject", "Message" [, "From", "Additional Headers"]);<br>*/<br>mail($ToEmail, $ToSubject, $Message, $from);<br><br>Print "_root.EmailStatus=Complete.";<br>?>Using the above code should work as you wish, with PHP 4.1 and up.
~Brett