By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,795 Members | 1,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,795 IT Pros & Developers. It's quick & easy.

Email handler problem

P: n/a
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 wrong.

Just for background info, when I click submit the form sends okay, but when
the email arrives in my inbox the $name value is non-existent - like nothing
had been entered in the box on the web page form.

Also, I'm not sure if this is relevant: The server uses PHP version 4.4.4
The form handler: (scripts/ct_em.php)

<?
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;

mail( "ME@MYDOMAIN.COM", "SUBJECT OF THE EMAIL",
"NAME: $name \n\n
EMAIL ADDRESS: $email \n\n
MESSAGE FOLLOWS BELOW: \n
$message",
"From: $email" );
header( "Location: THANK-YOU PAGE" );
?>
The form: (03_contact.html) - it should be noted that I've got a Javascript
validation script that checks the length of the value of the email address
field to ensure that it's not left blank - it's had no impact on the form
working or not working - when the form did work this Javascript was always
present.

<form enctype="multipart/form-data" method="post" action="scripts/ct_em.php"
name="form1">

<table width=288 cellpadding=0 cellspacing=0>
<tr valign=center>
<td class="body_mid" width=288>Name:<br><input name="name"
style="font-size: 12px; width: 288px; height: 19px;"></td>
</tr>
<tr valign=center>
<td width=288 height=5></td>
</tr>
<tr valign=center>
<td class="body_mid" width=288>Email address:<br><input name="email"
style="font-size: 12px; width: 288px; height: 19px;"></td>
</tr>
<tr valign=center>
<td width=288 height=5></td>
</tr>
<tr valign=top>
<td class="body_mid" width=288>Your message:<br><textarea name="message"
style="font-family: Arial; font-size: 12px; width: 288px; height:
50px;"></textarea></td>
</tr>
<tr valign=center>
<td width=288 height=10></td>
</tr>
<tr valign=center>
<td width=288><a href="javascript:document.form1.submit()"
OnMouseOver="se.src='images/bu_se_lt.gif'"
OnMouseOut="se.src='images/bu_se_dk.gif'" onClick="return validate();"><img
name="se" id="se" src="images/bu_se_dk.gif" alt="Send" border="0"></a></td>
</tr>
</table>

</form>

Thanks for your time folks!

Regards,

Danny.
Nov 20 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Am Mon, 20 Nov 2006 21:59:18 GMT schrieb Danny Smith:
<?
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;

mail( "ME@MYDOMAIN.COM", "SUBJECT OF THE EMAIL",
"NAME: $name \n\n
Just try to set your $name variable before you use it :)
$name = $_REQUEST['name'] ;

Best Regards,
Fabian Fuchs
Nov 20 '06 #2

P: n/a
Danny Smith wrote:
... It used to work correctly ...
register_globals
http://www.php.net/manual/en/security.globals.php

Add these two lines at the very top of your script, right after the
first <?php tag

error_reporting(E_ALL);
ini_set('display_errors', '1');

With this configuration, PHP will let you know when you try to use an
inexistent variable.

--
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
Nov 20 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.