Jump to content

Recommended Posts

:-\

Hi all

Ive read through the various FAQs on this subject here and elsewhere and managed to fix a few header errors etc but ive hit a dead end. 

I got my code here:

[url=http://www.christian-web-masters.com/articles/web_php-mail-form-2.html]http://www.christian-web-masters.com/articles/web_php-mail-form-2.html[/url]

its a simple code for sending form data. the page containing the form is " who.php " and the processing file is " process.php " which can be found here:

[url=http://www.supasleuth.com/beats/who.php]www.supasleuth.com/beats/who.php[/url] and

[url=http://www.supasleuth.com/beats/process.php]www.supasleuth.com/beats/process.php[/url]

the problem is that although the return works fine i dont receieve the email with the data.

im hopeful that the error would be obvious to more php-experienced eyes than mine.  if anyone can take a moment to have a look i'll be grateful. (Im  using dreamweaver six and notepad ).

Cheers

MS

Link to comment
https://forums.phpfreaks.com/topic/15983-sending-form-data-through-email/
Share on other sites

[quote author=pixy link=topic=102282.msg405697#msg405697 date=1154224489]
Post the code you're using in process.php (we can't see it through a browser).
[/quote]

Sorry!! 

Here's the code


[b]process.php[/b] :
"

<?php
@extract($_POST);
$email = stripslashes($email);
mail('runamokg@yahoo.com',$subject,$text,"From: <$email>");
header("location:who.php");
?>

"


Taken from [b]who.php[/b] (file containing the form) :

"
Sign up for updates

<form action="process.php" method="post">


E-mail:
<center><input type="text" name="email">
<input type="submit" value="Send">

</form>
"


Can anone spot a fault?

Cheers
There were several things wrong with that script. Here is one that I wrote for you. It uses rather simple mail headers but it should do the trick. Give it a try.

[b]The new process.php[/b]


[code=php:0]<?php
$email = $_POST['email']
$email = stripslashes($email);

//checks to make sure that an email address was entered
if (!$email) {
    echo "You did not enter an email address";
    include("who.php");
    exit;
}
/*Now this section is realy all a matter of personal perference
I would personaly rather want to know what the email address meant.
You can change the subject to anything that you want*/

$to = "you@youremail.com";
$subject = "You have received a request for updates";
$message = "Hellow webmaster,
A person at YourSite.com as requested updates. There email address is as follows.
$email";
/*This section here contains the mail information.  You were  trying to use the From
as the users email address.*/
mail($to, $subject, $message, "From: Update Request<you@yoursite.com>\nX-Mailer: PHP/" . phpversion()) or die("Unable to send mail");
echo "Your request has been sent and we will reply shortly";
include("who.php");
?>[/code]

Hope this helps,
Tom
Im getting this error message:

Parse error: parse error, unexpected T_VARIABLE in /home/groots/public_html/supasleuth/beats/process.php on line 3


THis is how process.php is now


<?php
$email = $_POST['email']
$email = stripslashes($email);
if (!$email) {
    echo "You did not enter an email address";
    include("who.php");
    exit;
}
$to = "you@youremail.com";
$subject = "You have received a request for updates";
$message = "Hellow webmaster,
A person at YourSite.com as requested updates. There email address is as follows.
$email";
mail($to, $subject, $message, "From: Update Request<you@yoursite.com>\nX-Mailer: PHP/" . phpversion()) or die("Unable to send mail");
echo "Your request has been sent and we will reply shortly";
include("who.php");
?>

Any ideas what might be up with this??

Again cheers for the help!

MS
try this ok.
[code]
<?php
$email = ($_POST['email']);
$email = stripslashes($email);
if (!$email) {
    echo "You did not enter an email address";
    include("who.php");
    exit;
}else{
$to = "you@youremail.com";
$subject = "You have received a request for updates";
$message = "Hellow webmaster,
A person at YourSite.com as requested updates. There email address is as follows.
$email";
mail($to, $subject, $message, "From: Update Request<you@yoursite.com>\nX-Mailer: PHP/" . phpversion()) or die("Unable to send mail");
echo "Your request has been sent and we will reply shortly";
include("who.php");
}
?>
[/code]
Cheers redarrow.

that code [i]appears[/i] to work fine. the error and thank you messages work as and when needed.  the only problem is im not getting the emails through  :-[


the only changes i made were to insert my email addy to line 9 :

$to = "skivatron@aol.com";

and line 14:

mail($to, $subject, $message, "From: Update Request<skivatron@aol.com>\nX-Mailer: PHP/" . phpversion()) or die("Unable to send mail");

I feel like im getting closer..cheers for all the help!!! 

Can anyone see what might be wrong?

MS
There you go mate fully done just add your email address ok.

this should work and if so you need to keep hold off what works for you i strongly advise you to backup a copy if it works.

good luck ok.

[code]
<?php

$email = ($_POST['email']);
$email = stripslashes($email);
if (!$email) {
echo "You did not enter an email address";
include("who.php");
exit;
}else{
$to      = 'nobody@example.com';
$subject = 'You have received a request for updates';
$message = 'Hellow webmaster,
A person at YourSite.com as requested updates. There email address is as follows.
$email';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
echo 'Your request has been sent and we will reply shortly';
include("who.php");
}
?>
[/code]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.