Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm writing up my first website and I am down to the last part; the contact form. Everything has been just HTML5 and CSS so far. From the searches I've done online it would seem that PHP is necessary to make contact forms. Is that true? If not what are some other ways? I'm guess making a contact form with just HTML5 and CSS isn't possible.
Is PHP absolutely necessary to make a contact form?
PHP, no. A server side scripting language of some description, yes.
PHP is generally used because it's common and is shipped with most standard web servers.
You could also use ASP, Python, node.js, whatever you want.
I'm guess making a contact form with just HTML5 and CSS isn't possible.
Making the form is, you just won't be able to send any emails without it.
The only way you could achieve this without using your own server side validation is to use someone else's (i.e. a third party to send your email for you). You'll still be exposing your connection to them, which isn't ideal.
Just add it with PHP if your web server has it installed already! See the documentation for examples. Otherwise there's plenty of tutorials online if you search "[language here] contact form tutorial".
No, PHP is not necessary. To make a contact form which a user can send you'll need some kind of a server-side implementation, and PHP is one of the easiest ways to go.
But you are correct in that HTML and CSS wont be enough.
You could send an email directly from the user's device to your email address using javascript like this
window.open('mailto:oliver#example.com?subject=subject&body=body');
the subject and body could be made from the form content. When you receive the email, you do what you want with it.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm in the process of learning more PHP. I've not really done any PHP before, only enough for basic emailing on contact forms. In the past when I've made such forms I've occasionally had spam emails come through via that script. From the frequency of the emails and the content it is very much apparent that it isn't someone coming on the website and spamming via the form but rather they know the url of the php file and are submitting data to it via that in some way; what is the best way to prevent this sort of thing happening.
If you're in your very early stages of PHP (or programming in general) I would recommend that you create an input in your form which you hide or move off screen using css.
This would mean that no real user would fill this, but when when a bots comes to your page and submit the form, they would fill it in with some garbage data.
In your php code handling the submission, simply check to see if this field has been submitted or not. If it has then you know it was not a real person, so discard the submission and do not proceed further with sending the email.
Note: I'm only recommending the approach above for learning purposes and for tiny projects that are not really in production use. If you need a more robust solution, then look into some sort of capcha solution or some javascript that adds some csrf type of checks to your form.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
first of all, sorry for bad english. Please correct me if I write something wrong!
I'm a "noob" in the programing scene, so I need some help. I want to help my mom to automate a process at her bussines. The core thing I need to do are this:
I need to extract info from a webpage (it's an php webpage), and compare the products that arrive with the one's displayed in the webpage. I want to do that scanning the bar codes of the products (I've a database of all the products barcodes). Then I need to save the comparission in a file just to make sure that everything is ok. I want to know wich languague is better for my case. (Then I will try to do it, fail, learn from my mistakes and then have some "stable" program to do this)
TL;DR: I recive products, I check if everything arrived in a website. I want to do that using bar codes and "automate" the process. I want to know wich languague is better for my case.
Thank you!!
As others pointed out in the coments, there is not best language, you need to chose the one that fits you.
But let me give you some recommendations on what might work.
You said that the site is already in PHP, that's the backend language. You should keep using it since a part of the site is already built with it. Other options are JavaScript using NodeJS, Python, Java, Ruby.
You can do almost everything you need in the backend (server side) using PHP, but some things might be better to solve them in the client side (front end) using JavaScript, is the default language that runs on the browsers.
Usually you use the backend language to serve pages, interact with a database, send data to the client. And the front end (JavaScript) to add dynamic functionality to your website.
Web apps used to depend a lot on the backend, reloading the page for every action, sending a lot of information back and forth.
The modern aproach to build web apps (like yours) is a bit more dependant on JavaScript. You load the page once and then just do AJAX (Asynchronous JavaScript and XML) requests to the server asking just for the information you need and showing it dynamicly with out reloading and having to load the HTML/CSS all over again. Many frameworks like Angular, React (with its whole ecosystem), help you a lot with it.
Read more about it here.
EDIT: just to clirify, I answered with some recommendations and opinions because it is what the question asks for.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm currently working on a PHP application. In order for me to post data to the website, I create a simple form, nothing trivial. However, I would like to incorporate a functionality of posting data in the form of email. So I have a webserver, I have an email set up, and what I would like to do is to send a message to that email, then the sent data is stored. I'm trying to find resources how to do this one and to no avail. Any kind of help is appreciated, thanks in advance.
Mailgun has an inbound email API, which will post incoming email messages to your application. See http://www.mailgun.com/inbound-routing. Sendgrid also offers a similar service: https://sendgrid.com/blog/sendgrids-parse-api-parsing-incoming-email-is-now-faster-and-easier/
It's called email piping, and its a bit hands on so far as configuring it with your email server. If you're comfortable, here's a decent quick rundown: http://www.phpshare.org/articles/Piping-Incoming-Mail-with-PHP
I believe the above is what you're looking for, however an alternative would be having a specific subject / attachment name, and having a cron job periodically check your email account looking for that specific string. ( Option A is a much better / easier fit, but thought it was worth mentioning).
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am creating a form that users will use to register for an event. However, I just discovered that there are some really tight security limitations due to policies due to the site's hosting and also policies the organization has about external-facing scripts (such as PHP) that are seen as an unneeded vulnerability.
I haven't been told flat-out that all PHP is completely banned, but I think that I won't be able to create a file and send email with it. However, I do want to be able to have an online registration form that can be filled out and emailed in as low-tech a way as possible.
I'm aware that you can use mailto: to prepopulate the subject and body of an email sent through the users normal email client:
mailto:my#addy.com?subject=subject+here&body=body+of+email
This is not the best solution because not everyone will be able to use mailto in this way, and for those that do, they must be relied upon not to mess up the formatting of the email. It isn't very consistent. Is there anything better than mailto: but which is still less of a security risk than PHP?
If you don't have the ability to run server side code, then sending an email is pretty much out of the question. Unless of course, you can make javascript calls to some other website that emails or store the form information for you.
Your best bet might be outsourcing it entirely, and using a Google Doc form or something.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
How can I go about implementing a database like search form into an HTML website? For example, there is a form to enter your zip code and after entering the zip code, it searches a .txt file (for example) and returns results that fall under that specific zip code.
Any help would be greatly appreciated.
Thank you
There are many approaches you could take. It's a very broad question.
As an example solution, you would need to have both client and server side code. The client would submit the form to a server. The server code could be written in a multitude of languages, PHP, ASP, JAVA etc.
The server side code would take the request parameters sent by the form, read the file, calculate any result and pass it back in the http response to the front end, which could be dealt with by displaying a new page or as part of an AJAX refresh.
As you can appreciate though, this is a very broad topic and there are many possible solutions.
Also as #Dagon points out, if you are not restricted to using a text file (although your title probably suggests you are) then using a MySQL or other such database could be a better solution, maybe even Solr as an indexing solution, depending on what you are searching for.