SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Member
    Join Date
    Mar 2013
    Location
    Ottawa, Ontario
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem woth Godday hosted site and forms

    Hi there,

    I'm pulling my hair out to figure out this problem I'm having with a form: it accepts the form once I click "submit" (I get the message "Thank you for the message. We will contact you shortly.", which is in my php file), but no emails are received on my end. I try different e-mails, and nothing. Godaddy says they want me to use their special php file and enter the recipient email via a web page (log in, navigate to page and enter the email address) which is something I don't want to do: I want to just modify the php file I created and not their interface (which is a royal pain).
    Here is my HTML code in a file called contact_us_test.html:

    HTML Code:
    <form action="contact.php" method="get" name="contact">
              <table width="100%" border="0" cellpadding="5">
                <tr>
                  <td colspan="2">&nbsp;</td>
                  </tr>
                <tr>
                  <td colspan="2">&nbsp;</td>
                  </tr>
                <tr>
                  <td align="right"><label for="name">Full Name/label></td>
                  <td><input type="text" name="name" id="name" /></td>
                </tr>
                <tr>
                  <td align="right"><label for="email">Email Address/label></td>
                  <td><input type="text" name="email" id="email" /></td>
                </tr>
                <tr>
                  <td align="right"><label for="phone">Phone number with area code/label></td>
                  <td><input type="text" name="phone" id="phone" /></td>
                </tr>
                <tr>
                  <td height="138" colspan="2" align="right" valign="top"><label for="message">How may we help you?</label>
                    <textarea name="message" id="message" cols="60" rows="10
                    "></textarea></td>
                  </tr>
    
                <tr>
                  <td colspan="2" align="center"><label for="submit"></label>
                    <input type="submit" name="submit" id="submit" value="Submit" /></td>
                  </tr>
                <tr>
                  <td align="right">&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
              </table>
            </form>
    and here is the php file called contact.php

    PHP Code:
    <?php
    $field_name 
    $_POST['name'];
    $field_phone $_POST['phone'];
    $field_email $_POST['email'];
    $field_message $_POST['message'];


    $mail_to 'sales@fixit2sellit.com';
    $subject 'Message from a site visitor '.$field_name;

    $body_message 'From: '.$field_name."\n";
    $body_message .= 'E-mail: '.$field_email."\n";
    $body_message .= 'Message: '.$field_message;

    $headers 'From: '."myname@mydomain.com"; <---- NOTE:  I've inputted the correct email here (checked with 3 different ones) , and it's not on their list of prohibited domains.
    $headers .= 'Reply-To: '.$field_email."\r\n";

    $mail_status mail($mail_to$subject$body_message$headers);

    if (
    $mail_status) { ?>
        <script language="javascript" type="text/javascript">
            alert('Thank you for the message. We will contact you shortly.');
            window.location = 'contact_us_test.html';
        </script>
    <?php
    }
    else { 
    ?>
        <script language="javascript" type="text/javascript">
            alert('Message failed. Please, send an email to lblanchet@fixit2sellit.com');
            window.location = 'contact_us_test.html';
        </script>
    <?php
    }
    ?>
    Anything jump out at you as en error?
    Last edited by Force Flow; Mar 13, 2013 at 19:32. Reason: added code tags

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,203
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Hi Limoges_designer. Welcome to the forums.

    Quote Originally Posted by Limoges_designer View Post
    Anything jump out at you as en error?
    Yup. Using GoDaddy as a web host.

    Of course, I could bang on about the inappropriate use of tables, but I'll spare you that!

    If there's an issue with the PHP, that will be a question for the PHP forum, though on first gance it looks OK to me. But it sounds like GoDaddy has its own requirements anyhow, so it may not matter if this form code works in theory.

    I don't like the use of JS to post messages, though. Why not just echo a message on the page, or send the user to a thankyou/error page?

  3. #3
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    You should be using "post" as your form method, not "get".

    Everything in your PHP code is referencing the $_POST variable, not the $_GET variable.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  4. #4
    SitePoint Member
    Join Date
    Mar 2013
    Location
    Ottawa, Ontario
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Force Flow View Post
    You should be using "post" as your form method, not "get".

    Everything in your PHP code is referencing the $_POST variable, not the $_GET variable.
    OMG: you rock! Of course!!!!!! It worked right away!

  5. #5
    SitePoint Member
    Join Date
    Mar 2013
    Location
    Ottawa, Ontario
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    Hi Limoges_designer. Welcome to the forums.



    Yup. Using GoDaddy as a web host.

    Of course, I could bang on about the inappropriate use of tables, but I'll spare you that!

    If there's an issue with the PHP, that will be a question for the PHP forum, though on first gance it looks OK to me. But it sounds like GoDaddy has its own requirements anyhow, so it may not matter if this form code works in theory.

    I don't like the use of JS to post messages, though. Why not just echo a message on the page, or send the user to a thankyou/error page?
    I figured I was a new guy at developing web site, so I thought this was the appropriate location. I'll look for the right location next time.

    What's wrong with my tables? If it works, I'm good with it. I had issues with tables within a form within a table within a div section, so I changed it around a bit.

    I had to let Godaddy mess with the sender email address or they wouldn't let the email get sent. I tried to get rid of the override, but you can't do that. Man, I don't like their hosting - I want to change it for someone else...

    I added some spry validation - as well as a neat little bot catcher: I posted an image (so bots have a hard time figuring out) asking what 9 + 7 is, and then made a filed that only accepts a value between 16 and 16. (that sound you hear is me patting myself on the back!

  6. #6
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,203
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Good catch Force Flow. I missed that.

    Quote Originally Posted by Limoges_designer View Post
    What's wrong with my tables? If it works, I'm good with it.
    Well, "works" is a debateable concept. HTML markup has a meaning, and tables are for organising content in columns and rows ... so a screen reader will often try to read the content out that way ... Meh, anyway ... you can find out why tables are a poor layout choice, but it's up to you.

    I had to let Godaddy mess with the sender email address ... I want to change it for someone else...
    Yes, they are OK with domains, but are not considered a good option for web hosting.

    I added some spry validation
    I believe that's JS, right? JS validation is handy for users, but it's not all that useful for protecting a form. Best to employ some server-side protection.

    I posted an image (so bots have a hard time figuring out) asking what 9 + 7 is
    It's good to have extra honeypots, but try closing your eyes and filling out the form—how will you go then. The best practice goal in web design is to make sites as accessible as possible, so do keep your blind and otherwise impaired visitors in mind.

  7. #7
    SitePoint Member
    Join Date
    Mar 2013
    Location
    Ottawa, Ontario
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    Good catch Force Flow. I missed that.



    Well, "works" is a debateable concept. HTML markup has a meaning, and tables are for organising content in columns and rows ... so a screen reader will often try to read the content out that way ... Meh, anyway ... you can find out why tables are a poor layout choice, but it's up to you.



    Yes, they are OK with domains, but are not considered a good option for web hosting.



    I believe that's JS, right? JS validation is handy for users, but it's not all that useful for protecting a form. Best to employ some server-side protection.



    It's good to have extra honeypots, but try closing your eyes and filling out the form—how will you go then. The best practice goal in web design is to make sites as accessible as possible, so do keep your blind and otherwise impaired visitors in mind.
    It's been so long since I did any web design, so I'm maybe missing something here: the "alt" tag in images: what does it do? Can the visually-impaired read it? If so, I have added the information there.

    Any articles that I can read on server side verification - and do I really need it? What is the threat potential from having non-server side verification? I just want people to fill in the correct formats: I'm catering to homeowners in my area that want renovation work done.

    Also: I REALLY appreciate how quickly, intelligently and friendly the replies are here. I do this kind of advice in an HVAC thread on a similar type of site, and I pride myself in giving good advice.

  8. #8
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,203
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by Limoges_designer View Post
    the "alt" tag in images: what does it do? Can the visually-impaired read it? If so, I have added the information there.
    Indeed they can. I'm not sure if there are any restrictions to using it in forms, or what the experience would be like for blind users. @Stomme poes knows a lot about this, so let's see if she has any comment.

    server side verification - and do I really need it?
    Unfortunately, without it your form can be used as a vehicle for mass spamming via various code injections. I'm not too good in this area, but you could Google something like "form code injections" and "cross-site scripting" for more info on this.

    I REALLY appreciate how quickly, intelligently and friendly the replies are here.
    That's nice to hear. We do try to be helpful around here. We can't guarantee that we can give the right answers, but we'll always try.

  9. #9
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,278
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    Hi,

    I see an error in all the labels, where you close them:
    <td align="right"><label for="name">Full Name/label></td>

    Missing that < bracket means your labels never close.

    As far as screen readers are concerned, at least the ones with a virtual buffer (JAWS, NVDA, Window-Eyes on Windows), the table doesn't matter: once you're in a form, you're in Forms Mode and all the table elements are ignored, unless you deliberately take yourself OUT of Forms Mode to hear everything (but that means your keystrokes are for navigation and won't fill in the inputs).

    If you use alt text for the image, it kinda defeats the purpose of the image (if you were using an image so bots couldn't see the question). So I'd just have it be a regular label instead. If you insist on an image, then yes, use alt text.

    The good news is, most of the bots wandering around out there don't have built-in math capabilities to answer those questions, even though it would be super easy for anyone to add. You also get the possibility of making things a bit harder for the cognitively impaired, like people with (I kid you not) dyscalulia. I like honeypots a bit more for this reason.

    You can probably find a lot about honeypots in forms online, but the rule for anyone using a screen reader is generally so: make sure there are instructions in the label that tell humans what the right thing to do is. You can prevent the majority of users from ever running across these honeypots by using Javascript to remove them and send instead the appropriate answer to your server... then only users without JS and bots actually have to deal with the honeypot, and the honeypot question should be easy for the humans.

  10. #10
    SitePoint Member
    Join Date
    Mar 2013
    Location
    Ottawa, Ontario
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stomme poes View Post
    Hi,

    I see an error in all the labels, where you close them:
    <td align="right"><label for="name">Full Name/label></td>
    Missing that < bracket means your labels never close.
    That problem got fixed - thanks!
    Quote Originally Posted by Stomme poes View Post


    As far as screen readers are concerned, at least the ones with a virtual buffer (JAWS, NVDA, Window-Eyes on Windows), the table doesn't matter: once you're in a form, you're in Forms Mode and all the table elements are ignored, unless you deliberately take yourself OUT of Forms Mode to hear everything (but that means your keystrokes are for navigation and won't fill in the inputs).

    If you use alt text for the image, it kinda defeats the purpose of the image (if you were using an image so bots couldn't see the question). So I'd just have it be a regular label instead. If you insist on an image, then yes, use alt text.

    The good news is, most of the bots wandering around out there don't have built-in math capabilities to answer those questions, even though it would be super easy for anyone to add. You also get the possibility of making things a bit harder for the cognitively impaired, like people with (I kid you not) dyscalulia. I like honeypots a bit more for this reason.

    You can probably find a lot about honeypots in forms online, but the rule for anyone using a screen reader is generally so: make sure there are instructions in the label that tell humans what the right thing to do is. You can prevent the majority of users from ever running across these honeypots by using Javascript to remove them and send instead the appropriate answer to your server... then only users without JS and bots actually have to deal with the honeypot, and the honeypot question should be easy for the humans.
    thanks!

  11. #11
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,278
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    Your name makes me think of Limoges- the marketplace.

    https://www.youtube.com/watch?v=MpzuYXxoe7c

  12. #12
    SitePoint Member
    Join Date
    Mar 2013
    Location
    Ottawa, Ontario
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stomme poes View Post
    Your name makes me think of Limoges- the marketplace.

    https://www.youtube.com/watch?v=MpzuYXxoe7c
    It's a village just outside of Ottawa, Ontario. Named after a pastor who lived in the area, and is also the name of a famous city in France.


Bookmarks

Posting Permissions

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