Forums

Give help. Get help.

  • # December 23, 2012 at 6:18 pm

    .

    # December 23, 2012 at 6:20 pm

    Here is the HTML:

    # December 23, 2012 at 6:33 pm

    @Eric, I have the code in place, I’m simply missing something small, I believe. Can you offer a shorter solution than editing all the above code to match mine? Thank you very much sir!

    # December 23, 2012 at 6:41 pm

    @Eric, or anyone … If I’m using .PHP to submit a contact form, can I also use JS to validate the form?

    # December 23, 2012 at 6:48 pm

    I’m in over my head with PHP and JS … I had a friend write this contact submit form code, and am lost!

    # December 23, 2012 at 6:52 pm

    Okay, I will try this @Eric, thank you. To be clear, will I still be using the PHP to send the form to the email address? This new line of JS will work hand in hand with the PHP, correct? My above PHP code does work, but it just won’t make the fields REQUIRED. Will the above JS make the fields REQUIRED? Thank you sir!

    # December 23, 2012 at 6:59 pm

    Okay, so then I’ll please wait if someone else can offer a resolution! Thanks @Eric. Anyone if you have way to add just this one tweak, PLEASE HELP!

    __
    # December 24, 2012 at 2:17 am

    @hendrix – I don’t see any of your code?

    However, I will say this:

    You need to consider that **javascript is not secure**. JavaScript validation is great for the user – to make their experience using your form happier – but it is **not** a replacement for server-side validation. JS can be turned off. JS can be manipulated. It is under the complete control of the user, and therefore, *cannot be trusted*.

    Server-side validation is **always necessary**.

    Also,

    > This new line of JS will work hand in hand with the PHP, correct?

    **Edit**: I may have misunderstood your question, here. No, they don’t work together (i.e., they don’t *interact*), but you may have been asking if they would *conflict* with each other? If so, that’s unlikely. **/edit**

    No. Javascript and PHP cannot “work together.” They don’t run at the same time, or even on the same computer:

    …PHP runs *first*, **on your server**. When it’s done, it sends its output (typically HTML markup + JavaScript code) to the user’s browser. **Then it stops**.

    …JavaScript runs *later*, **on the user’s computer**. It has *no clue* that PHP ever existed.

    *****
    If you’re still trying to figure this out, please point me to your code, and I’d be happy to help.

    # December 24, 2012 at 11:43 am

    @traq, thank you very much for your detailed explanation. Please, remind me the best way to get all the code to you for examination? I believe you suggested GitHub?

    __
    # December 24, 2012 at 12:45 pm

    I’ve suggested that before, yes –

    (1) copy+paste your code to [gist.github.com](http://gist.github.com)

    (2) **** out any sensitive/secure info

    (3) click on [Create Public Gist] and share the URL

    I was only asking because your initial posts seem to have originally contained code, but do not now. Your original question seems to be missing as well – unless this thread is a continuation of your earlier [CONTACT FORM not working … please help!!](http://css-tricks.com/forums/discussion/comment/86155#Comment_86155) thread? Either way, it would be good if you could explain again where you are with your problem.

    # December 26, 2012 at 9:06 pm

    @traq, thank you sir. Here’s the link to the GIST with the PHP and HTML code:

    __
    # December 27, 2012 at 12:09 am

    https://gist.github.com/4385576

    BTW, your email **is not** “from” the user. It’s “from” your website. Putting the user’s email address here will get your email dropped or flagged as spam by some mail servers or clients.

    The `From` email address should always belong to a domain that is allowed to send mail from your mail server (e.g., *your* domain). The easiest solution here is a no-reply address. For example, if my website was `example.com`, I’d use `no-reply@example.com`.

    If you want to include the user’s email in the headers, the `Reply-to` field is a good place for it.

    __
    # December 27, 2012 at 4:29 pm

    @Eric **do not** use ereg() – it’s deprecated. Use [preg_match()](http://php.net/preg_match) instead.

    Why include the spam answer in your email?

    # December 27, 2012 at 4:38 pm

    @traq, I’ll check everything once I get home. Thank you very much for taking the time to post sir.

    # December 27, 2012 at 8:55 pm

    @traq, I copied and pasted the code, but kept getting errors. I’ll recheck in a bit when I can upload the code. Thank you for your help.

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

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag