Jump to content

Archived

This topic is now archived and is closed to further replies.

supa

sending form data through email

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

Share this post


Link to post
Share on other sites
Post the code you're using in process.php (we can't see it through a browser).

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Hi Tom

many thanks on this one.. your help is greatly appreciated..

im on it right now il let peeps know how i get on!!

Cheers

M






Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Daym still not working.

Worse the validity check doesn't work now.   No - the validity check does work (modification to post).

Thanks for your patience mate.  I dont have a clue what's up.   

???

Share this post


Link to post
Share on other sites
Thers no error im just not getting the mail through.

Share this post


Link to post
Share on other sites
PHP has no way of reporting that the mail was sent, it just tells the mailserver to send a message. I'd say just double check your variables and such.

Share this post


Link to post
Share on other sites
There also a possibility that a spam filter etc is blocking it...

Share this post


Link to post
Share on other sites

×

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.