Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Trying to make our text fields in contact form REQUIRED! Frustrated!! PLEASE HELP!

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 27 total)
  • Author
    Posts
  • #41561
    hendrix940
    Participant

    .

    #118785
    hendrix940
    Participant

    Here is the HTML:

    #118793
    hendrix940
    Participant

    @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!

    #118795
    hendrix940
    Participant

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

    #118798
    hendrix940
    Participant

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

    #118800
    hendrix940
    Participant

    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!

    #118802
    hendrix940
    Participant

    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!

    #118818
    __
    Participant

    @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.

    #118859
    hendrix940
    Participant

    @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?

    #118866
    __
    Participant

    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!!](https://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.

    #119095
    hendrix940
    Participant

    @traq, thank you sir. Here’s the link to the GIST with the PHP and HTML code:
    https://gist.github.com/4384872

    #119099
    __
    Participant

    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 `[email protected]`.

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

    #119151
    __
    Participant

    @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?

    #119152
    hendrix940
    Participant

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

    #119162
    hendrix940
    Participant

    @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)
  • The forum ‘CSS’ is closed to new topics and replies.