Jump to content

Urgent help needed with php form to email script


Glen_S

Recommended Posts

I am not a coder, so please bear with me.

 

I have used this program called web form designer to create a few forms now, all of them using their sample php script that I modified for my own use (as per their tutorial).

 

Here is the problem, and I have just noticed it when someone pointed out that they are getting errors trying to use the email form and I could not figure out why as it worked fine for me.

 

What happened is, when I registered my domain I did not bother to reigister it with the www prefix, just mydomain.com. The trouble is, when someone types a www.mydomain.com it takes them to my page ok, then if they go to the contact me page and fill out the email form, the referring url does not match the current www url, and I get this error:

 

ERROR: You do not have permission to use this script from another URL. Referer: www.mydomain.com This URL: mydomain.com

 

I have this form on a few sites now, so I am eager to know how I can fix this and still make sure the email is coming from my page. I was thinking I could delete the code that checks for the referring url, but I'd sooner not just do this.

 

This is the code in the script that runs when someone presses submit:

 

// Get the URL of this page

    $this_url = strtolower($_SERVER['HTTP_HOST']);

 

    // If the referring URL and the URL of this page don't match then

    // display a message and don't do download or send the email.

    if ($referer != $this_url) {

        echo "ERROR: You do not have permission to use this script from another URL. \n";

        echo "Referer: " .$referer . "\n";

        echo "This URL: " .$this_url. "\n";

        exit;

    }

 

Like I said, I do not know php well enough to do this, is there a way to modify this so I can still ensure my emails are coming from my page, but avoid the error when someone uses the www prefix?

 

thanks in advance

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.