Click to See Complete Forum and Search --> : Contact forum help...


pixel-artist-2
05-11-2005, 11:45 PM
I got the form

<form method="POST" action="mailer.php">
<?php $ipi = getenv("REMOTE_ADDR"); ?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
&nbsp;Name:<br>
&nbsp;<input type="text" name="name" size="40" class="request">
<br>
<br>
&nbsp;Your email:<br>
&nbsp;<input type="text" name="email" size="40" class="request">
<br>
<br>
&nbsp;Message:<br>
&nbsp;<textarea rows="9" name="message" cols="100" class="request"></textarea>
<br>
<br>
&nbsp;<input type="submit" value="Submit" name="submit" class="request"></form>

and mailer.php
<?php
if(isset($_POST['submit'])) {
$to = "g33k@geek.cairns-hosting.com";
$subject = "Contact Form";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$ip = $_POST['ip'];

$body = "From: $name_field\n E-Mail: $email_field\n Message: $message\n IP: = $ip";

include('sent.php');
mail($to, $subject, $body);
} else {
echo "There was an error";
}
?>

But when I receive the mail, it has no "from" part and just says nobody

It just bugs me. :rolleyes:

GUIR
05-12-2005, 12:19 AM
Hi!

First I've to tell you I am very new to PHP, and had the same problem last week, which now you have !

Now, I have solved it by modifying following code. Actually as I know there should be fourth optional parameter header for your requirement.

$to = 'you@server.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@' . $_SERVER['SERVER_NAME'] . "\r\n" .
'Reply-To: webmaster@' . $_SERVER['SERVER_NAME'] . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

There is a comprehensive tutorial at http://www.php.net/function.mail

Regards... :)

pixel-artist-2
05-12-2005, 07:56 PM
It worked. :cool:

Thanks alot.

EDIT: I don't know what section to put this under...

How do you make it so e-mail input has to be in e-mail format?

GUIR
05-12-2005, 08:15 PM
You are welcome.

How do you make it so e-mail input has to be in e-mail format?

It's not clear what do you mean by above.

Do you need to check a given email address in correct syntax or not?

Otherwise, want to have emails in HTML format.? May be other... Let me know.

As said earlier, I'm also new to PHP. But I know how to do above things.

GUIR

pixel-artist-2
05-14-2005, 01:47 PM
You are welcome.



It's not clear what do you mean by above.

Do you need to check a given email address in correct syntax or not?

Otherwise, want to have emails in HTML format.? May be other... Let me know.

As said earlier, I'm also new to PHP. But I know how to do above things.

GUIR


I mean like it has to be like this, someone@somewhere.com

GUIR
05-16-2005, 01:47 PM
Hi!

Just replace following part webmaster@' . $_SERVER['SERVER_NAME']

with

'someone@someone.com'

I guess that you are looking for that.

Regards...