Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

website form validation and email send

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys,
i am a very greenhorn with websites, css and javascript (I used to create java apps) and i need some help please:

I created the website from a template, it looks good and everything but i am not sure how to validate my form and send the email:
my form:


I found this validator online: will this work for me?


another newbie question, this is the php email handler: do i just put this file in the root directory? when i do there are a lot of errors that doesn't make sense...

your help will be highly appreciated..
 
Ben van Jaarsveld
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

The errors in the php script has been sorted out no problem,

The extra field that are required have been inserted

But where do i put the php file? in the root?
also what does the validator do? do I need it? doesn't the html validate the fields automatically?
Thanks
 
Saloon Keeper
Posts: 6977
164
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HTML is a markup language that validates nothing by itself. Whether you need the JavaScript validator depends on, well, whether you need a client-side validator :-) We don't know what you're trying to achieve so we can't tell. But you seem to do some validation in the PHP code as well (which is where it needs to happen anyway), so further client-side validation may not be necessary.

You'd put the PHP file wherever it makes sense to be put. Just make sure that the URL you use for accessing it reflects the full path to it. If you want a URL like "www.mysite.com/sendEmail.php", then it would go into the root directory. If you want it to be "www.mysite.com/foobar/sendEmail.php", then it goes into the subdirectory "foobar".
 
Saloon Keeper
Posts: 23703
161
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Root directory" is a dangerous term here. What you actually have is known specifically to Apache as documentRoot, as opposed, to, say, the root directory for the entire machine filesystem.

Each website hosted by a webapp server has a documentRoot directory - at least for web programming environments that are predicated on being directory-based. The directory location is a configuration parameter, and for many Linux systems, it's defined by default to be either /var/www or /var/www/html. PHP webapps, however, are often installed in their own directories, and while there are conventions, you can actually put them anywhere you prefer.

Almost. The filesystem root directory would be a very bad choice, for example, since you're potentially exposing the entire OS to be plundered by webapp remote clients.
 
Sheriff
Posts: 67537
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:HTML is a markup language that validates nothing by itself.


Not completely accurate. The HTML5 form elements have rudimentary validation built in; such as required, pattern, min, max, type, and so on.

More complex, or cross-field validations require some JS code.
reply
    Bookmark Topic Watch Topic
  • New Topic