/    Sign up×
Community /Pin to ProfileBookmark

Contact forum help…

I got the form

[code=html]<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>[/code]

and mailer.php

[code=php] <?php
if(isset($_POST[‘submit’])) {
$to = “[email protected]”;
$subject = “Contact Form”;
$name_field = $_POST[‘name’];
$email_field = $_POST[’email’];
$message = $_POST[‘message’];
$ip = $_POST[‘ip’];

$body = “From: $name_fieldn E-Mail: $email_fieldn Message: $messagen IP: = $ip”;

include(‘sent.php’);
mail($to, $subject, $body);
} else {
echo “There was an error”;
}
?> [/code]

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

It just bugs me. :rolleyes:

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@GUIRMay 12.2005 — 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 [b][i]header[/b][/i] for your requirement.

[code=php]$to = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@' . $_SERVER['SERVER_NAME'] . "rn" .
'Reply-To: webmaster@' . $_SERVER['SERVER_NAME'] . "rn" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);[/code]


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

Regards... ?
Copy linkTweet thisAlerts:
@pixel-artist-2authorMay 13.2005 — It worked. ?

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?
Copy linkTweet thisAlerts:
@GUIRMay 13.2005 — You are welcome.

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

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
Copy linkTweet thisAlerts:
@pixel-artist-2authorMay 14.2005 — 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[/QUOTE]



I mean like it has to be like this, [email][email protected][/email]
Copy linkTweet thisAlerts:
@GUIRMay 16.2005 — Hi!

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

with

'[email protected]'[/QUOTE]

I guess that you are looking for that.

Regards...
×

Success!

Help @pixel-artist-2 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...