Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP Mail Form no longer working

Featured Replies

Hi,

 

Been using a pretty standard PHP mail form successfully for a while now, but just bought some more webspace from Easyspace (a new account) and it no longer works.

 

Strange thing is, it worked last week (and still does) on my other account, which is also through Easyspace.

 

Surey it has to be something to do with their web hosting - but I've emailed them and they've said it's not at their end!

 

Here's the script -

 

<?php

 

$name = $HTTP_POST_VARS['name'];

$email = $HTTP_POST_VARS['email'];

$phone = $HTTP_POST_VARS['phone number'];

$message = $HTTP_POST_VARS['message'];

 

$name = stripslashes($name);

$email = stripslashes($email);

$phone = stripslashes($phone);

$message = stripslashes($message);

 

$rec_email = 'info@mywebsite.co.uk';

$subject = "Mywebsite Web Query";

 

$msg_body .= "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\n";

$msg_body .= "Name: $name\n";

$msg_body .= "E-Mail: $email\n";

$msg_body .= "Phone Number: $phone\n";

$msg_body .= "Message: $message\n";

$msg_body .= "_____________________________________________\n";

 

$header_info = "From: $email";

$sender = 'webquery@mywebsite.co.uk';

mail($rec_email, $subject, $msg_body, $header_info, '-f'.$sender);

 

?>

 

Sometimes it returns just the headers with no values, sometimes it doesn't even seem to send.

 

This is really frustrating me and easyspace have been rubbish in helping.

 

Any ideas?

 

TIA

Your accounts could be running on different servers which have different versions of PHP running.

 

$HTTP_POST_VARS is deprecated in PHP5 which could possibly cause your script not to work at all on your new server.

  • Author
Your accounts could be running on different servers which have different versions of PHP running.

 

$HTTP_POST_VARS is deprecated in PHP5 which could possibly cause your script not to work at all on your new server.

 

Hi, thanks for the response.

 

The new version is running at v4.3.10.

 

Do you have any ideas and/or suggestions?

 

Thanks

My first suggestion would be to catch up to PHP 5 and get a server which supports it, but I understand if you have something that works you don't want to redo it.

 

The PHP code looks fine to me, don't see any problems with it so I'm afraid I don't have any suggestions. I would have immediately thought it was server sided issues.

 

Goodluck with it

  • Author
My first suggestion would be to catch up to PHP 5 and get a server which supports it, but I understand if you have something that works you don't want to redo it.

 

The PHP code looks fine to me, don't see any problems with it so I'm afraid I don't have any suggestions. I would have immediately thought it was server sided issues.

 

Goodluck with it

 

Hi, thanks for the help.

 

Looking at Easyspace homepage, it looks as though PHP is version 5.1.6, so the sales advisor may have been wrong.

 

Assuming that this is true, what can I do to my mail form script to make it work?

 

Much appreciated, and help would be great.

 

TIA

Enter

phpinfo();

in your PHP code, you'll get a bunch of information. Right at the very top, in the PHP header, it'll tell you the version of PHP that you're actually using.

 

To update to PHP5, you'd replace

$HTTP_POST_VARS

with

$_POST

 

When you say you sometimes get blank messages, and at other times it doesn't even send, is this testing done with the form filled with data valid? You have to make sure they enter a valid email address because it's used in the message header, and may not send the mail properly if it's not set.

 

I think you're on PHP5, which can't use HTTP_POST_VARS, in turn your email headers arent being set properly, and therefore your mail isn't being sent.

  • Author
Enter

phpinfo();

in your PHP code, you'll get a bunch of information. Right at the very top, in the PHP header, it'll tell you the version of PHP that you're actually using.

 

To update to PHP5, you'd replace

$HTTP_POST_VARS

with

$_POST

 

When you say you sometimes get blank messages, and at other times it doesn't even send, is this testing done with the form filled with data valid? You have to make sure they enter a valid email address because it's used in the message header, and may not send the mail properly if it's not set.

 

I think you're on PHP5, which can't use HTTP_POST_VARS, in turn your email headers arent being set properly, and therefore your mail isn't being sent.

 

Hi mate.

 

Tried replacing 'HTTP_POST_VARS' with '$_POST' for all four input fields and received the following email:

 

Name: _level0.LOADER.Content.Contact_Form.input_name

E-Mail: _level0.LOADER.Content.Contact_Form.input_email

Phone Number: _level0.LOADER.Content.Contact_Form.input_phone

Message: _level0.LOADER.Content.Contact_Form.input_message

Normally, there are just the headers (Name: E-mail: etc) with blank values but now there's the errors...

 

Any ideas?

 

I definitely feel we're getting somewhere though, many thanks

Before we go any further, can you confirm we are dealing with PHP5 by placing

 

phpinfo();

 

in your code. This will display a huge table of information but all I need to know is the header of the table, it should say something like: "PHP Version 5.2.8".

 

Also, can you paste the code which actually takes the user input and posts it.

  • Author
Before we go any further, can you confirm we are dealing with PHP5 by placing

 

phpinfo();

 

in your code. This will display a huge table of information but all I need to know is the header of the table, it should say something like: "PHP Version 5.2.8".

 

Also, can you paste the code which actually takes the user input and posts it.

Sorry mate, where do I put the php(info); line? Into the php file or the index.html?

 

Tried putting it in the mail_form.php file, but cannot get in to view...

 

TIA

  • Author
Sorry mate, where do I put the php(info); line? Into the php file or the index.html?

 

Tried putting it in the mail_form.php file, but cannot get in to view...

 

TIA

 

Ah, it actually posts the php data after about 10 seconds....

 

Windows NT WEB03 5.2 build 3790

Dec 8 2008 19:30:48

 

How cool is that!!

 

Any help?

  • Author

Here is the code I use to send the info...

 

on (release) {

if (!_parent.input_email.text.length || _parent.input_email.text.indexOf("@") == -1 || _parent.input_email.text.indexOf(".") == -1) {

_parent.Status = "Valid Email Required";

} else {

_parent.Status = "Message Sent!!";

name = _parent.input_name;

email = _parent.input_email;

phone = _parent.input_phone;

message = _parent.input_message;

loadVariablesNum("Mail_Form.php",0,'POST');

_parent.gotoAndPlay("submitted");

_parent.borders.gotoAndPlay("off");

}

}

 

Hope this helps mate - fingers crossed

 

Regards

  • Author

Sorry mate, I'm jumping about all over here, and probably confusing you...

 

Have done some tests on old and new servers.

 

Old server is php version 4.4.6

New server is php version 5.2.8

 

THAT explains why the mail form is working on old servers still but not on new servers.

 

God, I hope this helps (and HOW bad are easyspace tech help!!)

 

Regards

Ok so we have the problem.

 

on (release) {
if (!_parent.input_email.text.length || _parent.input_email.text.indexOf("@") == -1 || _parent.input_email.text.indexOf(".") == -1) {
_parent.Status = "Valid Email Required";
} else {
_parent.Status = "Message Sent!!";
name = _parent.input_name;
email = _parent.input_email;
phone = _parent.input_phone;
message = _parent.input_message;
loadVariablesNum("Mail_Form.php",0,'POST');
_parent.gotoAndPlay("submitted");
_parent.borders.gotoAndPlay("off");
}
}

 

What language is this? Actionscript or something? I meant the code for the form that the user fills out and clicks submit. Pasting your whole contact page code would help.

  • Author

It's flash, using a program called swishmax 2.

 

Can't really give you the whole code as it's divided into sections - here's a break down of the main parts:

 

Here's the contact form code:

 

onSelfEvent (load) {

System.useCodePage=true;

}

onFrame (1) {

input_name.text="Name";

input_email.text="Email";

input_phone.text="Phone Number";

input_message.text="Message";

status = "";

}

onFrame (2, afterPlacedObjectEvents) {

stop();

}

onFrame (56, afterPlacedObjectEvents) {

setLabel("submitted");

}

onFrame (300) {

gotoAndPlay(1);

}

 

name field -

 

onSelfEvent (load) {

this._text.onSetFocus=function(){

if (this.text=="Name"){

this.text=""; }

else{

this.text=this.text; }

 

_parent.borders.gotoAndPlay("name");};

this._text.onKillFocus=function(){

if (this.text==""){

this.text="Name"; }

else{

this.text=this.text; }

 

};

}

 

Email field -

 

onSelfEvent (load) {

this._text.onSetFocus=function(){

if (this.text=="Email"){

this.text=""; }

else{

this.text=this.text; }

 

_parent.borders.gotoAndPlay("email");};

this._text.onKillFocus=function(){

if (this.text==""){

this.text="Email"; }

else{

this.text=this.text; }

 

};

}

 

phone field -

 

onSelfEvent (load) {

this._text.onSetFocus=function(){

if (this.text=="Phone Number"){

this.text=""; }

else{

this.text=this.text; }

 

_parent.borders.gotoAndPlay("phone");};

this._text.onKillFocus=function(){

if (this.text==""){

this.text="Phone Number"; }

else{

this.text=this.text; }

 

};

}

 

Message field -

 

onSelfEvent (load) {

this._text.onSetFocus=function(){

if (this.text=="Message"){

this.text=""; }

else{

this.text=this.text; }

 

_parent.borders.gotoAndPlay("message");};

this._text.onKillFocus=function(){

if (this.text==""){

this.text="Message"; }

else{

this.text=this.text; }

 

};

}

 

Send button code -

 

on (rollOver) {

gotoAndPlay("on");

}

on (rollOut) {

gotoAndPlay("off");

}

on (release) {

if (!_parent.input_email.text.length || _parent.input_email.text.indexOf("@") == -1 || _parent.input_email.text.indexOf(".") == -1) {

_parent.Status = "Valid Email Required";

} else {

_parent.Status = "Message Sent!!";

name = _parent.input_name;

email = _parent.input_email;

phone = _parent.input_phone;

message = _parent.input_message;

loadVariablesNum("Mail_Form.php",0,'POST');

_parent.gotoAndPlay("submitted");

_parent.borders.gotoAndPlay("off");

}

}

I'm not by any means an expert on Flash so I'm not sure, sorry mate.

 

Although the error seems it would be with the PHP file, I really can't see anything wrong with it. The only thing suspect to me is the 5 parameters for the mail() function.

 

Normally I only have four:

 

("mymail@gmail.com", $subject, $message, $from);

  • Author
I'm not by any means an expert on Flash so I'm not sure, sorry mate.

 

Although the error seems it would be with the PHP file, I really can't see anything wrong with it. The only thing suspect to me is the 5 parameters for the mail() function.

 

Normally I only have four:

 

("mymail@gmail.com", $subject, $message, $from);

 

thanks for trying mate, here is the mail_form.php script as it stands now...

 

<?php

phpinfo();

$name = $_POST['name'];

$email = $_POST['email'];

$phone = $_POST['phone'];

$message = $_POST['message'];

 

$name = stripslashes($name);

$email = stripslashes($email);

$phone = stripslashes($phone);

$message = stripslashes($message);

 

$rec_email = 'info@mysite.co.uk';

$subject = "Mysite Web Query";

 

$msg_body .= "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\n";

$msg_body .= "Name: $name\n";

$msg_body .= "E-Mail: $email\n";

$msg_body .= "Phone Number: $phone\n";

$msg_body .= "Message: $message\n";

$msg_body .= "_____________________________________________\n";

 

$header_info = "From: $email";

$sender = 'webquery@mysite.co.uk';

mail($rec_email, $subject, $msg_body, $header_info, '-f'.$sender);

 

?>

 

This is a nightmare :(

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.