php formmail doesn't work after domain changed

hopefully I’m not posting in the wrong place. First time here.

I was working on a school project and the formmail.php was given from the instructor is easy and works really good. The school ended so I signed up my own domain to save all the school works also to get more knowledge of how domain things work.

But the thing is, the formmail worked perfectly with the instructor’s domain/server after I transfered everything back to the server I signed up the formmail gives me two different errors randomly when submitting the formmail.

I know and remember I had to change this in the php file in order to work.

$referers = array(‘’,‘’); I need to put in the domain in which I did but I still get the errors though. I have totally 0 knowledge about php so I searched up a bit on the net and lots were talking about changing the domain which of course I did but I still get the errors. Anyone able to give me a hand?
The above is my own site with all the transfered files and so this contact page uses the formmail.php after filling the info and upon submitting I get either one of the errors below

Anyone able to give me a hand here with simple english instead I have no knowledge of php or programmings?

Thanks in advance

Well, without seeing any code, I can tell you what the first error JPEG shows.

It is just as the error states, the function is deprecated. That means it should no longer be used. Instead of eregi() you should likely be using preg_match()

The header error below that is due to the first error being output to the browser.

If you want to keep using eregi you can suppress the errors by adding @ before the function.

For example,


You will have to post your code for the second problem.

For the second problem, two things that i can think of (without seeing the code) are 1, the method attribute isn’t set or is improper or 2, your fields don’t have names.

which part of the code should I copy and paste? Because everything worked fine until I transferred the files onto another domain/server.

m@tt: after adding @eregi the first error doesn’t seem to appear anymore but keeps on appearing the second error.

It was pretty random but often the first time I fill in and submit the first time, the first error will appear then if I go back and fill again the second error will appear. With m@tt’s help by adding @ the first error seems to be gone just keep on showing up the second error.

Should I post the code where I use the formmail.php or what codes should I post? :slight_smile:

Thanks everyone

You should post your form (html) and the formmail.php code

This is the html code (But by formmail.php code you mean the whole formmail.php codes? Because it’s like 500 lines*


	<!--Where this form is submitted to-->
	<input type="hidden" name="recipient" id="recipient" value="[email protected]" />
	<!--What the subject line will be-->
	<input type="hidden" name="subject" id="subject" value="Contact From MAD LTD" />
	<!--After submitting the form, where the page will be redirected to-->
	<input type="hidden" name="redirect" id="redirect" value="thanks.html" />
	<!--Sorts how info will be listed in the email.  This is the names in the inputs below-->
	<input type="hidden" name="sort" id="sort" value="order:name,email,purpose,sub,comments,unit,street,city,province,post,phone" />

<table class="table2">
<tr><!--name row-->
	<td><label>Name: </label></td>
	<td><input type="text" name="name" id="name" size="40" /></td>

<tr><!--email row-->
	<td><label>Email: </label></td>
	<td><input type="text" name="email" id="email" size="40" /></td>

<tr><!--purpose row-->
	<td><label>Purpose: </label></td>
	<td><select name="purpose" id="purpose">
			<option selected="selected">Please Choose...</option>
			<option value="FAQ">F.A.Q.</option>
			<option value="Woman">Woman Products</option>
			<option value="Man">Man Products</option>
			<option value="Feedback">Feedback</option>
			<option value="Online Order">Online Orders</option>
			<option value="Other">Other</option>

<tr><!--Subject row-->
	<td><label>Subject </label></td>
	<td><input type="text" name="sub" id="sub" size="40" /></td>

<tr><!--Comments row-->
	<td colspan="2">
		<textarea name="comments" id="comments" rows="6" cols="50"></textarea>

<tr><td colspan="2" class="reminder">*Address only needed if you are placing orders*</td></tr>

<tr><!--unit row-->
	<td><label>Unit #: </label></td>
	<td><input type="text" name="unit" id="unit" size="10" /></td>

<tr><!--street row-->
	<td><label>Street: </label></td>
	<td><input type="text" name="street" id="street" size="30" /></td>

<tr><!--city row-->
	<td><label>City: </label></td>
	<td><input type="text" name="city" id="city" size="30" /></td>

<tr><!--province row-->
	<td><label>Province </label></td>
	<td><input type="text" name="province" id="province" size="30" /></td>

<tr><!--Postal row-->
	<td><label>Postal Code: </label></td>
	<td><input type="text" name="post" id="post" size="6" /></td>

<tr><!--Tel row-->
	<td><label>Mobile Phone: </label></td>
	<td><input type="text" name="phone" id="phone" size="15" /></td>

	<td colspan="2" class="reminder">*Reminder - If you are placing order, please write in as much details as possible.  Thanks*</td>

	<td><input type="submit" value=" Submit " /></td>
	<td><input type="reset" value=" Reset " /></td>


You can post it, just be sure to use the ‘code’ and ‘php’ tags - also remove any personal information.

So when I post the formmail.php I should delete all the comments the author left in there too?
Because I paste it all and the forum says exceed 2000 characters so I couldn’t post.

You must have some type of commercial mail script for it to be that big. I’m not sure how you can post it. If you upload it somewhere and post the link or PM it to me, maybe?

the code link is in

That has to be the most complicated form code i’ve ever seen, most if it isn’t even needed, but it looks like the problem may be with $referers. Basically, you have to list every possible domain for anyone that might use the form. This is from the manual:

$referers = array("","");

This array allows you to define the domains that you will allow forms to reside on and use your PHPFormMail script. If a user tries to put a form on another server, that is not in your list, they will receive an error message when someone tries to fill out their form. By placing boaddrink in the $referers array, this DOES NOT allow,, any other http address with in it. I included’s IP address to access this script as well, just to be on the safe side. As of version 1.5.0 you can now use regular expressions in the $referers array.

Note: The domains listed in the $referers array must also include the domain that the e-mail is going to.

Example: If the recipient of the e-mail is [email protected] and the form is hosted on, your $referers array will have to look like

$referers = array(“”, “”);

Remember, the domain name of the recipient’s domain must be listed in the $referer array, even if the form isn’t hosted on that domain. Rule of thumb, include the domain name that is hosting the form AND include the domain name of the recipients (This includes recipient, recipient_cc, and recipient_bcc).

The instructor told us for this formmail.php the $referers is the only thing we need to change to make it work and changing that $referers into the domain where the formmail.php is kept that’s why I added in it. When the file was uploaded into the instructor’s personal domain I had to change the into to get it work since that’s the domain where the students upload the files. The is because in the html I added my email so my email receives the info being put in the form.

I heard others say it’s because the host/domain of uses php 4.3 or higher and the formmail.php is not accepting eregi(). But since I have no knowledge of php I tried searching to debug but couldn’t even undersatnd a thing.

If your host really is using 5.0 or higher, its possible the function might not be there at all, which means you’ll have to switch to preg_match().

as for the referers, i was going off what the manual was saying. The big issue seems to that it doesn’t like to use subdomains unless they’re listed, so instead of putting just, include the site’s ipaddress also.

I don’t think it has to do with the referrers because the code never makes it to the referrer check.

I just submit the form and didn’t get an error

Idk what the problem is then.

You and me both :wink: As I mentioned… I submit the form and didn’t get any errors. So I wonder if this is a browser issue of some kind. There’s nothing in the code (that I can see) that would cause that script to fail.

If you want to completely rule out the referrer as a possible problem, it looks like you can change this value to false:

[php]define(‘CHECK_REFERER’, true);[/php]

O.o that’s weird…I just tried too and no error…but I didn’t do any changes o.O

I tried using preg_match() but didn’t work too and I used site’s ip too but just didn’t try both ip and domain name…

But somehow it worked now so weird…but nothing was changed after my last post

I just found something funny. I said it suddenly worked right? So I tried the second time then that second error message about no data …post or get error message…I tried both of firefox 16.0 and chrome canary. Then I went to my laptop to try and same thing…first time worked second time the error again…so I tried as matt said changing the referer to false then upload…again worked the first time and failed the second time … weird O.o

guess I will have to find another formmail any good suggestions for formmail that’s pretty user friendly?

You could always try coding your own :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service