1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

contact form, could anyone look it over not getting errors just not receiving the email

Discussion in 'Programming & Webmastering' started by Sean8, Jan 9, 2014.

  1. Sean8

    Joined:
    Mar 7, 2009
    Messages:
    289 (0.14/day)
    Thanks Received:
    10
    PHP:
    <?php

    // Your Name
    $your_name ="$your name";

    // Mail of sender
    $your_email="$your email";


    // Phone Number
    $phone_number="$phone number";


    // Subject
    $subject="$subject";

    // Your Message
    $your_message="$your message";


    // Enter your email address
    $to ='info@mydomain.com';

    $send_contact=mail($your_name,$your_email,$phone_number,$subject,$your_message);


    // Check, if message sent to your email
    // display message "We've recived your information"
    if($send_contact){
    echo 
    "We've recived your contact information";
    }
    else {
    echo 
    "ERROR";
    }
    ?>



    <table width="960" border="0" cellpadding="0">
      <tr>
      <td><form id="form1" name="form1" method="post" action="contact.php">
      <p>
      <label>Your Name (required)
      <br />
      <input type="text" name="your name" id="your name" />
      </label>
      </p>
      <p>
      <label>Your Email (required)
      <br />
      <input type="text" name="your email" id="your email" />
      </label>
      </p>
      <p>
      <label>Your Phone No.<br />
      <input type="text" name="phone number" id="phone number" />
      </label>
      </p>
      <p>
      <label>Subject<br />
      <input type="text" name="subject" id="subject" />
      </label>
      </p>
      <p>
      <label>Your Message<br />
      <textarea name="your message" id="your message" cols="65" rows="5"></textarea>
      </label>
      </p>
      <p>
      <input name="submit" type="submit" id="submit" onclick="MM_validateForm('your name','','R','your email','','R');return document.MM_returnValue" value="Submit" />
      </p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      </form></td>
      </tr>
    </table>
     
    Last edited by a moderator: Jan 10, 2014
  2. Exceededgoku

    Joined:
    Mar 26, 2006
    Messages:
    410 (0.13/day)
    Thanks Received:
    24
    Looks to be fine unfortunately; What version of PHP is running on the server? Is there any firewall in place.

    One thing I've noticed is that you change from double quotes to single quotes for the to address:

    $to ='info@mydomain.com';
     
  3. Sean8

    Joined:
    Mar 7, 2009
    Messages:
    289 (0.14/day)
    Thanks Received:
    10
    php 5.4.21

    fixed the quote issue, changed the email address to send too also, same problem
     
    Last edited: Jan 9, 2014
  4. Exceededgoku

    Joined:
    Mar 26, 2006
    Messages:
    410 (0.13/day)
    Thanks Received:
    24
    Oh and big no no is space in names for variables. Use underscore or dashes if you really want to keep words separated. <--- Ignore this, I read it wrong...

    I'll put your code onto my website and see if it makes more sense in a HTML editor.

    EDIT - Have a look at this example: http://www.freecontactform.com/email_form.php
     
    Last edited: Jan 9, 2014
  5. Sean8

    Joined:
    Mar 7, 2009
    Messages:
    289 (0.14/day)
    Thanks Received:
    10
    hopefully you will be able to find the problem, i will look at that example. It has something to do with sending i know that lol

    im very new to php
     
  6. hellrazor

    hellrazor

    Joined:
    Feb 18, 2010
    Messages:
    1,576 (0.94/day)
    Thanks Received:
    318
    Use code tags next time.
     
    Mindweaver says thanks.
  7. Sean8

    Joined:
    Mar 7, 2009
    Messages:
    289 (0.14/day)
    Thanks Received:
    10
    anything else you can contribute?

    has anyone else had a chance to look over it to see what I'm missing?
     
  8. Easy Rhino

    Easy Rhino Linux Advocate

    Joined:
    Nov 13, 2006
    Messages:
    13,422 (4.68/day)
    Thanks Received:
    3,240
    I am confused by the topic? So your form is fine. Your problem is you are not getting the email? Do you have an email server setup to send email????
     
  9. Mindweaver

    Mindweaver Moderato®™ Staff Member

    Joined:
    Apr 16, 2009
    Messages:
    5,205 (2.62/day)
    Thanks Received:
    2,691
    Location:
    Statesville, NC
    Yea your form is fine. I'm with Easy Rhino do you have an email server setup? Also, you can test run php code online here. Paste your PHP code in and run code in the future. :toast:

    EDIT: Forgot to add that last little part.. lol
     
    Last edited: Jan 10, 2014
    Crunching for Team TPU
  10. Solaris17

    Solaris17 Creator Solaris Utility DVD

    Joined:
    Aug 16, 2005
    Messages:
    17,206 (5.18/day)
    Thanks Received:
    3,565
    Location:
    Florida
    do you have sendmail enabled on your server?
     
  11. silentbogo

    silentbogo

    Joined:
    Nov 20, 2013
    Messages:
    153 (0.50/day)
    Thanks Received:
    46
    Did you check the Spam folder? Most of the time if email comes from the unknown source - it is automatically moved to the spam folder. Had a similar problem with email redirection for one of my customer's project.
    Another major problem is that you mail it wrong.
    The correct syntax for mail is:
    PHP:
    bool mail string $to string $subject string $message [, string $additional_headers [,string $additional_parameters ]] )
    .. so your "from" email is sent as a subject, phone # as the message and the actual message is considered an additional header for sendmail.
    try it this way:
    PHP:
    $to      'someone@mail.com';
    $subject 'subject';
    $message 'message';
    $headers 'From: me@example.com' "\r\n" .
        
    'Reply-To: me@example.com';

    if(
    mail($to$subject$message$headers))
    {
      echo 
    "message sent!";
    }
    else echo
    "Error!!!";
    ?>
     

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page