new issue: email problem
  • kentakerouskentakerous
    April 2012
    hey Mike, things are progressing nicely with the template, thanks again for making it so well-documented.

    What's happening now is a bit of a problem with emailing. I'm pretty sure I did things right with the page and yet the emails don't go through and it kicks back an error, as follows :
    *
    Deprecated: Function eregi() is deprecated in D:\Hosting\9185147\html\contact.php on line 18
    *
    I have no idea how to address this; I replaced the email address as instructed in the php form, and I've tried it a few times just to see if I was doing any copy/paste errors, but the error still happens.

    This is not loading from disk, this is the actual online site kicking back this error. Can you offer any advice? Thanks for your time.
  • mikemike
    April 2012
    It's likely your local hosting. I suggest uploading the form to a web server to test it out. We use the same form on all our items and have no reports of issues. Chances are your hosting is missing the PHP mailer required to send out e-mails. If this continues when you post it live, post a link.
  • kentakerouskentakerous
    April 2012
    What I am saying is that this problem is happening after I've posted it live, to a web server at godaddy where the site is posted. Here is the page:

    http://stevewoodmusicinstitute.com/contact.html
  • mikemike
    April 2012
    Try downloading the contact form again and starting over with the contact form. The contact form should not be referencing any local hosting "D:\Hosting\9185147\html\contact.php " in the error. Looks like it's trying to send the request back via your local host.
  • kentakerouskentakerous
    April 2012
    Okay I'll try that.

    Question: could this problem possibly be caused by referencing an email address not associated with the domain? This is hosted at godaddy but the email is an sbcglobal account. Would that make any difference?
  • mikemike
    April 2012
    Nope, that won't make a difference. You can also contact go daddy and see if that shared hosting server is missing any PHP mailer or etc required to send mail. This would be very uncommon but a chance to sorting it out.
  • kentakerouskentakerous
    April 2012
    Okay, I just uploaded a fresh contact page and contact.php. All I did was replace the email address in the php file. This is not loading from disk, this is the live file. I tried using one of my own email addresses this time, and it did send the email.

    But it still kicks back that error!! This gets stranger as I go along. I will call godaddy tomorrow and see if they have any insights.
  • mikemike
    April 2012
    Yeah, it's an odd one. If Godaddy isn't helpful, private message me an FTP login and URL. I'll try and help you out. Chances are the hosting provider is having some sort of forwarding issues.
  • kentakerouskentakerous
    April 2012
    okay thanks Mike, I'll try and get this handled tomorrow.
  • kentakerouskentakerous
    April 2012
    hey how do I private message you?
  • mikemike
    April 2012
    Click on my name or profile pic and then on the left column it will give you an option for "Send a private message".
  • kentakerouskentakerous
    April 2012
    Tomorrow I will be on the phone with godaddy about this deprecated function. I did some googling and there were quite a bit of entries about ereg functions and the version of php.
  • kentakerouskentakerous
    April 2012
    Some of the google results say eregi is deprecated in php 5.3.0. Could it be that the php version at godaddy is the problem?
  • mikemike
    April 2012
    Possibly, try upgrading to PHP5 or higher. GoDaddy does have a lot of issues and it's likely on there end. We use the form in over 4,000 files so it's pretty bullet proof.
  • kentakerouskentakerous
    April 2012
    Okay Mike, problem solved. The Function eregi() in line 18 of the contact.php file is deprecated in php v5.3, it doesn't work.

    godaddy always assigns the latest version of software to new accounts so the php was 5.3. This was causing the error message to show.

    godaddy has a control panel where, luckily, I was able to set my version of php to 5.2 and now the error is gone.

    They also sent an email with some info for updating the ergi for newer versions of php, so I'll have a look into that. Hopefully this thread is useful for you as well.
  • mikemike
    April 2012
    Awesome, thanks for the update
  • kentakerouskentakerous
    April 2012
    Actually Mike, I could use a bit of help to fix this problem in the code, because the solution is confusing. The examples they give for replacing the eregi function don't quite match what you've got in your code, and I don't want to break anything as I'm fixing it.

    Your code with the eregi is like this:
    if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
    $hasError = true;
    }


    Whereas the eregi example they use to update the code is as follows:
    if(!eregi("^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$", $str)) {
    $msg = 'email is not valid';
    }

    And they say this:
    "Use preg_match with the ‘i’ modifier instead. i means that regular expression is case insensitive. So the code become like this:"
    if(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $str)) {
    $msg = 'email is not valid';
    }


    (this is from http://takien.com/513/how-to-fix-function-eregi-is-deprecated-in-php-5-3-0.php)

    Can you have a quick look at these and provide an example of how your code would be fixed? I'm afraid I'll just break it. And this thread should prove very useful for other users that are running into this problem.

    Thanks very much for your time.

  • mikemike
    April 2012
    Sorry for taking a while to respond. This is an open source e-mail form that I did not create. I can't help trouble-shoot this if it's a server issue. There should be plenty of other open-source contact forms for you to use though if you search on google.com. You seem handy enough to easily drop the code in via a tutorial.
  • AistonAiston
    June 2012
    I also have GoDaddy and was able to fix the eregi problem with this code:
    } else if (!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$/i", trim($_POST['email']))) {
    $hasError = true;