Grow your CSS skills. Land your dream job.

Contact Post not displaying information

  • # February 17, 2013 at 11:14 pm

    Hey guys,

    I created a contact form on the website I have. (http://windbertsa.com/contact.html) I do receive comments from this post(I think spam because its the same time everyday). But, the emails only display “Name: Email: Comments:” They do not show anything else.

    I have a php file that looks like this:

    /* Email Variables */
    $emailSubject = ‘Windber-tsa!’; /*Make sure this matches the name of your file*/
    $webMaster = ‘***’;

    /*design by Mark Leroy @ http://www.helpvid.net*/

    /* Data Variables */
    $email = $_POST;
    $name = $_POST;
    $comments = $_POST;

    $body = < <


    Name: $name

    Email: $email

    Comments: $comments

    EOD;
    $headers = “From: $emailrn”;
    $headers .= “Content-type: text/htmlrn”;
    $success = mail($webMaster, $emailSubject, $body,
    $headers);

    /* Results rendered as HTML */
    $theResults = < <

    Your message has been sent successfully! Thank You for your message, We will respond promptly.


    EOD;
    echo “$theResults”;
    ?>

    And the form itself looks like this..


    Clear      Send

    I just do not understand why I do not get other information with these messages. Any help would be greatly appreciated!

    # February 17, 2013 at 11:53 pm

    You’re trying to access POST indexes that don’t exist (and, you never check to see if they exist or not).

    $email = $_POST;
    $name = $_POST;
    $comments = $_POST;

    Whereas your form has the inputs `Your Name`, `E-mail`, and an unnamed textarea.

    Give the textarea a name, and check when assigning your variables:

    < ?php

    $email = empty( $_POST )?
    ‘no email provided’:
    $_POST;

    // etc.

    # February 18, 2013 at 9:57 am

    First of all, Thanks!

    Where you have ‘$email = empty( $_POST )?’

    Should that value, e-mail, match the name of its respectable form element?

    # February 18, 2013 at 10:08 am

    @WindberTSA Yes, the string parsed into a global should match the `name` attribute of the input in question. Just another note, the `name` and `id` on an `input` element should be exactly the same and match the `for` attribute on the `label` so that, when a user clicks a label, the cursor is placed in the corresponding field.

    # February 18, 2013 at 10:15 am

    @tomrogers123 So it should look like this?


    Clear      Send

    # February 18, 2013 at 10:23 am

    Yes, apart from the fact that the inputs shouldn’t be __inside__ the labels.





    # February 18, 2013 at 10:26 am

    I’m not very good with forms or PHP. What does moving those labels and inputs do?

    # February 18, 2013 at 10:26 am

    Oh! That changed the way my form is displayed.. http://windbertsa.com/contact.html

    It also changed the way the comment ‘box’ enlarges. Before the image for that box would move with the input area enlarging, now it doesn’t enlarge..

    # February 18, 2013 at 10:53 am

    I know you probably don’t want the labels to be shown but they need to be in the markup for accessability reasons. You could remove them from display with;

    #contacts-form label {
    position: absolute;
    top: -99999px;
    left: -99999px;
    }

    As for getting the hint text inside the fields themselves, that’s what the HTML5 `placeholder` attribute is intended for.

    # February 18, 2013 at 11:10 am

    Okay, So I applied that style that you recommended but now the blue input boxes I had set are only showing for the comment not for the name or email field.

    # February 18, 2013 at 11:11 am

    On another note, The form itself is not sending any emails now..

    # February 18, 2013 at 11:19 am

    Sorry about that, any chance of an updated demo so I can see the latest issue?

    # February 18, 2013 at 11:23 am

    Yeah, I uploaded the changes.. http://windbertsa.com/contact.html

    # February 18, 2013 at 11:50 am

    Due to the fact that you had the inputs inside of labels before, you’re actually styling labels with styles that should be moved to inputs.As for the functionality, when did it stop working? Was it when you changed the PHP? If so, you need to make sure the `method` attribute on your form matches whatever you are using in PHP. If you have copied the code @traq suggested, you will need to change the `method` attribute in the markup to post so that they match.

    # February 18, 2013 at 12:16 pm

    So, everywhere in the CSS styling that i have ‘label’ I need to have input? This form thing is very confusing to me.. thanks again for your help!

    This is all the styling that I have applied to the form, or I guess previously applied..

    #contacts-form label { display:block; height:40px; background:url(../images/input.gif) no-repeat left top;}
    #contacts-form label input { width:260px; padding:4px 4px 2px 5px; color:#0f181e; border:none; background:none;}
    #contacts-form textarea {width:260px; height:102px; padding:2px 4px 2px 5px; color:#0f181e; overflow:auto; background:none; border:none;}
    #contacts-form .textarea { background:url(../images/textarea.gif) no-repeat left top; width:270px; height:107px; margin-bottom:30px;}
    #contacts-form label { position: absolute; top: -99999px; left: -99999px; }

    Well, the form never worked correctly to begin with, but it did send me messages without information. And This is what I have after changed what @traq suggested..

    /* Email Variables */
    $emailSubject = ‘Windber-tsa!’; /*Make sure this matches the name of your file*/
    $webMaster = ‘BradyA.Sheehan@gmail.com’;

    /* Data Variables */

    $email = empty ( $_POST )?
    ‘no email provided’:
    $_POST;

    $name = empty ( $_POST )?
    ‘no email provided’:
    $_POST;

    $comments = empty ( $_POST )?
    ‘no email provided’:
    $_POST;

    $body = < <


    Name: $name

    Email: $email

    Comments: $comments

    EOD;
    $headers = “From: $emailrn”;
    $headers .= “Content-type: text/htmlrn”;
    $success = mail($webMaster, $emailSubject, $body,
    $headers);

    /* Results rendered as HTML */
    $theResults = < <

    Your message has been sent successfully! Thank You for your message, We will respond promptly.


    EOD;
    echo “$theResults”;
    ?>

Viewing 15 posts - 1 through 15 (of 48 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".