473,387 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

PHP email form not working

I found this code for making a php email form for a web site. It works
fine on my ISP, but not on my friends...could it be that my ISP uses
php5, I know that hers does not, so I assume it's php4. Is there anyway
to tell? Here's the code. It sends me email fine, but when it's on her
ISP, it says it sent the mail, but nothing goes through.

<?php
if (isset($submit)) {
switch ($recipient) {
case "whole-family":
$recipient_email = "gr***@kcls.org";
$subject = "Gregs test php mail";
break;
case "Brian":
$recipient_email = "br***@meyer-family.com";
$subject = "Message to Brian";
break;
case "Jessica":
$recipient_email = "je*****@meyer-family.com";
$subject = "Message to Jessica";
break;
case "Eric":
$recipient_email = "er**@meyer-family.com";
$subject = "Message to Eric";
break;
case "Paul":
$recipient_email = "pa**@meyer-family.com";
$subject = "Message to Paul";
break;
case "Dudley":
$recipient_email = "du****@meyer-family.com";
$subject = "Message to Dudley";
break;
}

if (!empty($name) and !empty($email) and !empty($message)) {
if (mail ($recipient_email, $subject, $message, "From: $name
<$email>"))
$status = "<p>Thanks for your message, $name, it has been
successfully
sent!</p>";
else
$status = '<p>Your message couldnt be sent! Please try again or
send
us a conventional e-mail to
<a href="mailto:gr***@kcls.org">gr***@kcls.org</a>.
Thank you!</p>';
}
else
$status = "Please fill the highlighted fields!";
}
?>

<html>
<head>
<title>www.meyer-family.com - Contact</title>
<style type="text/css">
<!--
.error { font-weight: bold; color: red; }
-->
</style>
</head>
<body>
<h1>Contact</h1>
<?php
if(isset($status))
echo ($status);
?>
<form action="contact.php" method="post">
<p>Send message to:
<select name="recipient" size="1">
<option value="whole-family">The whole Meyer family</option>
<option value="Brian">Brian</option>
<option value="Jessica">Jessica</option>
<option value="Eric">Eric</option>
<option value="Paul">Paul</option>
<option value="Dudley">Dudley</option>
</select></p>
<p<?php
if (isset($submit) and empty($name))
echo(' class="error"');
?>>Your name:
<input type="text" name="name" value="<?php if(!empty($name))
echo($name); ?>" size="30"
/></p>
<p<?php
if (isset($submit) and empty($email))
echo(' class="error"');
?>>Your e-mail address:
<input type="text" name="email" value="<?php if(!empty($email))
echo($email); ?>"
size="30" /></p>
<p<?php
if (isset($submit) and empty($message))
echo(' class="error"');
?>>Your message:
<textarea name="message" cols="30" rows="5"><?php
if(!empty($message))
echo($message);
?></textarea></p>
<input type="submit" name="submit" value="Send" />
</form>
</body>
</html>

Jan 6 '07 #1
8 4465
Rik
alice wrote:
I found this code for making a php email form for a web site. It works
fine on my ISP, but not on my friends...could it be that my ISP uses
php5, I know that hers does not, so I assume it's php4. Is there
anyway to tell? Here's the code. It sends me email fine, but when
it's on her ISP, it says it sent the mail, but nothing goes through.
Look for register_globals and the $_POST array.
--
Rik Wasmus
Jan 6 '07 #2
Rik wrote:
alice wrote:
>>I found this code for making a php email form for a web site. It works
fine on my ISP, but not on my friends...could it be that my ISP uses
php5, I know that hers does not, so I assume it's php4. Is there
anyway to tell? Here's the code. It sends me email fine, but when
it's on her ISP, it says it sent the mail, but nothing goes through.


Look for register_globals and the $_POST array.
Here is a piece of code I found a long time ago that would extract all of the
get/post'ed variables if register_globals is off. Place this at the top of your
code...

if (!empty($_GET))
{
extract($_GET);
}
else if (!empty($HTTP_GET_VARS))
{
extract($HTTP_GET_VARS);
}

if (!empty($_POST))
{
extract($_POST);
}
else if (!empty($HTTP_POST_VARS))
{
extract($HTTP_POST_VARS);
}

--
Michael Austin.
Database Consultant
Jan 6 '07 #3
Actually, as it turns out, my ISP is using PHP 4.3 and hers, the one
where this code does not work, is using php 4.4. Should I still try the
code your talking about, would it make any difference? We also
discovered that other php mail/form code that she had on her ISP that
was working the day before, has suddenly stopped working, but we
haven't changed anything ourselves.

Michael Austin wrote:
Rik wrote:
alice wrote:
>I found this code for making a php email form for a web site. It works
fine on my ISP, but not on my friends...could it be that my ISP uses
php5, I know that hers does not, so I assume it's php4. Is there
anyway to tell? Here's the code. It sends me email fine, but when
it's on her ISP, it says it sent the mail, but nothing goes through.

Look for register_globals and the $_POST array.

Here is a piece of code I found a long time ago that would extract all of the
get/post'ed variables if register_globals is off. Place this at the top of your
code...

if (!empty($_GET))
{
extract($_GET);
}
else if (!empty($HTTP_GET_VARS))
{
extract($HTTP_GET_VARS);
}

if (!empty($_POST))
{
extract($_POST);
}
else if (!empty($HTTP_POST_VARS))
{
extract($HTTP_POST_VARS);
}

--
Michael Austin.
Database Consultant
Jan 6 '07 #4
alice wrote:
Actually, as it turns out, my ISP is using PHP 4.3 and hers, the one
where this code does not work, is using php 4.4. Should I still try the
code your talking about, would it make any difference? We also
discovered that other php mail/form code that she had on her ISP that
was working the day before, has suddenly stopped working, but we
haven't changed anything ourselves.

Michael Austin wrote:
>>Rik wrote:

>>>alice wrote:
I found this code for making a php email form for a web site. It works
fine on my ISP, but not on my friends...could it be that my ISP uses
php5, I know that hers does not, so I assume it's php4. Is there
anyway to tell? Here's the code. It sends me email fine, but when
it's on her ISP, it says it sent the mail, but nothing goes through.
Look for register_globals and the $_POST array.

Here is a piece of code I found a long time ago that would extract all of the
get/post'ed variables if register_globals is off. Place this at the top of your
code...

if (!empty($_GET))
{
extract($_GET);
}
else if (!empty($HTTP_GET_VARS))
{
extract($HTTP_GET_VARS);
}

if (!empty($_POST))
{
extract($_POST);
}
else if (!empty($HTTP_POST_VARS))
{
extract($HTTP_POST_VARS);
}

--
Michael Austin.
Database Consultant

It has to do with the register_global settings in the php.ini file. If you are
deploying this to multiple servers - I would include it as you really do not
know what the setting is going to be from server to server [for a given ISP].

--
Michael Austin.
Database Consultant
Jan 6 '07 #5
Rik
Michael Austin wrote:
alice wrote:
>Actually, as it turns out, my ISP is using PHP 4.3 and hers, the one
where this code does not work, is using php 4.4. Should I still try
the
code your talking about, would it make any difference? We also
discovered that other php mail/form code that she had on her ISP that
was working the day before, has suddenly stopped working, but we
haven't changed anything ourselves.

It has to do with the register_global settings in the php.ini file.
If you are deploying this to multiple servers - I would include it as
you really do not
know what the setting is going to be from server to server [for a
given ISP].
Well, an another script that previously worked suddenly stopped working I
doubt it.

I'd suggest the following:
Make a small script with a hardcoded mail() statement, which sends the mail
to an emailadress without spam filtering. If this doesn't work, yet mail()
returns true, contact your hoster. If it does, then try with
spam-filtering. If that also works, it's the variables in the script that
are the problem. Try to var_dump them instead of mail()ing , to check what
value they hold.
--
Rik Wasmus
Jan 6 '07 #6
Well now the code has started working again, and we did nothing. I
guess it was just a problem with the ISP.

Rik wrote:
Michael Austin wrote:
alice wrote:
Actually, as it turns out, my ISP is using PHP 4.3 and hers, the one
where this code does not work, is using php 4.4. Should I still try
the
code your talking about, would it make any difference? We also
discovered that other php mail/form code that she had on her ISP that
was working the day before, has suddenly stopped working, but we
haven't changed anything ourselves.
It has to do with the register_global settings in the php.ini file.
If you are deploying this to multiple servers - I would include it as
you really do not
know what the setting is going to be from server to server [for a
given ISP].

Well, an another script that previously worked suddenly stopped working I
doubt it.

I'd suggest the following:
Make a small script with a hardcoded mail() statement, which sends the mail
to an emailadress without spam filtering. If this doesn't work, yet mail()
returns true, contact your hoster. If it does, then try with
spam-filtering. If that also works, it's the variables in the script that
are the problem. Try to var_dump them instead of mail()ing , to check what
value they hold.
--
Rik Wasmus
Jan 7 '07 #7
I have a similar problem with a PHP script not sending email. I get an
error message with a syntax error T_VARIABLE missing in the line where
the mail() function is.

TIA

jiverbean
http://www.aibiver.com/
aside from my PHP woes, I have some JavaScript issues, but that's
another story

Jan 7 '07 #8
jiverbean wrote:
I have a similar problem with a PHP script not sending email. I get an
error message with a syntax error T_VARIABLE missing in the line where
the mail() function is.

TIA

jiverbean
http://www.aibiver.com/
aside from my PHP woes, I have some JavaScript issues, but that's
another story
I looked up the PHP manual, and thought the issue was due to the
whitespace (tabs, and newlines) in the concatenation of the mail
header.

There was a semi-colon missing in the statement before the line with
the error message.

Thanks for your patience,
jiverbean

Jan 8 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mindful_Spirit | last post by:
I'm trying to set up a basic email feed back form like this, and was wondering about some basic configuration settings. I have used code from this website. I have it working just fine. I'm...
88
by: Mike | last post by:
Is there a way to determine what a user's default email client is? I read a post from 3 years ago that said no. I guess I'm hoping something has come along since then.
4
by: web_design | last post by:
I put this together from some other scripts I am using on a site. I'm trying to make a better email hiding script. It isn't working. Also, it causes Internet Explorer 6 SP2 to block the script...
0
by: ng1 | last post by:
Hello , I am writing in order to get your valuable help . I have been working on a job which involves sending emails thorough Access. I created a form , a very simple one with a few fields to fill...
2
by: devine | last post by:
Hi All, I am trying to send an automatic email when an update has been made. My update statement will updates 6 fields, and dependant on one of the fields, I would like to send an email using CDO....
9
by: Jerim79 | last post by:
I am no PHP programmer. At my current job I made it known that I was no PHP programmer during the interview. Still they have given me a script to write with the understanding that it will take me a...
2
by: Danny Smith | last post by:
Hi folks, I'm having problems with my PHP form handler. It used to work correctly, but now for some reason its not. I'm hoping someone here could take a look and tell me where I might have gone...
5
stepterr
by: stepterr | last post by:
Hi Everyone, I'm new to PHP and have been working on an existing from that had been in Coldfusion but needed to be converted to PHP. I have most of it working except I ran into a problem when...
2
by: sindhudixit | last post by:
Hey, I am having a user fill out a form then the fields are going to uploaded to my database. So, at this point, when the user hits the submit button I want three things to happen: 1. The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.