Home › Forums › CSS › Trying to make our text fields in contact form REQUIRED! Frustrated!! PLEASE HELP!
- This topic is empty.
-
AuthorPosts
-
December 23, 2012 at 6:18 pm #41561
hendrix940
Participant.
December 23, 2012 at 6:20 pm #118785hendrix940
ParticipantHere is the HTML:
December 23, 2012 at 6:33 pm #118793hendrix940
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!
December 23, 2012 at 6:41 pm #118795hendrix940
Participant@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 #118798hendrix940
ParticipantI’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 #118800hendrix940
ParticipantOkay, 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 #118802hendrix940
ParticipantOkay, 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 #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.December 24, 2012 at 11:43 am #118859hendrix940
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?
December 24, 2012 at 12:45 pm #118866__
ParticipantI’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.
December 26, 2012 at 9:06 pm #119095hendrix940
Participant@traq, thank you sir. Here’s the link to the GIST with the PHP and HTML code:
https://gist.github.com/4384872December 27, 2012 at 12:09 am #119099__
Participanthttps://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.
December 27, 2012 at 4:29 pm #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?
December 27, 2012 at 4:38 pm #119152hendrix940
Participant@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 #119162hendrix940
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.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.