Results 1 to 2 of 2

Thread: PHP From Error

  1. #1
    Join Date
    Mar 2011
    Thanked 0 Times in 0 Posts

    Default PHP From Error

    Hi there, Ive set up a contact form on my website and so that some one can ask me a question and it will be sent to my e-mail address.

    Ive checked the e-mail address I am using and its set up to send and receive e-mails and Ive tested this.

    The php form seem to work as expected as well, i submit and it refreshes to the homepage and I get no errors, but once this has happened the e-mail never arrived to my e-mail account.

    My question is why is this? I'm stumped.

    The code im using is this:


    //--------------------------Set these paramaters--------------------------

    // Subject of email sent to you.
    $subject = 'Contact form';

    // Your email address. This is where the form information will be sent.
    $emailadd = '';

    // Where to redirect after form is processed.
    $url = '';

    // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
    $req = '0';

    // --------------------------Do not edit below this line--------------------------
    $text = "Results from form:\n\n";
    $space = ' ';
    $line = '
    foreach ($_POST as $key => $value)
    if ($req == '1')
    if ($value == '')
    {echo "$key is empty";die;}
    $j = strlen($key);
    if ($j >= 20)
    {echo "Name of form element $key cannot be longer than 20 characters";die;}
    $j = 20 - $j;
    for ($i = 1; $i <= $j; $i++)
    {$space .= ' ';}
    $value = str_replace('\n', "$line", $value);
    $conc = "{$key}:$space{$value}$line";
    $text .= $conc;
    $space = ' ';
    mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
    echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';


    <form action="sendresults.php" method="post" name="ContactForm">

    <label for="name">Name:</label>
    <input type="text" id="name" name="name" placeholder="Enter your full name" />

    <label for="email">Email:</label>
    <input type="text" id="email" name="email" placeholder="Enter your email address" />

    <label for="message">Message:</label>
    <textarea id="comments" name="comments" placeholder="What's on your mind?"></textarea>

    <input type="submit" name="Submit" value="Submit" />


    Maybe im stupid but im sure PHP is on the servers and part of the hosting plans with godaddy right? They host my site and e-mail address.

    Many Thanks if you can help

  2. #2
    Join Date
    Sep 2008
    Bristol - UK
    Thanked 132 Times in 131 Posts


    Try debugging the mail function with:

    PHP Code:
    if(mail($emailadd$subject$text'From: '.$emailadd.'')) {
    } else {

    If it fails, check with your host about what to do.

    The code looks fine, probably just not configured properly.

    Edit: For testing - remove this line under the mail function:

    PHP Code:
    echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts