Search This Blog

Friday, April 18, 2014

How does a contact form work?

Most contact forms these days have adopted PHP to make themselves work. Now php is a server based language and when your browser requests the server hosting it to open a php file, it gets executed instead. This is why you get a redirect or html file when you try to directly open a php file.

Scripting in HTML is platform dependent. I am using blogger to host this site. And since I'm using blogger, I cant really give you php demos here. This is because blogger does not support php. If I ought to buy a domain and build a website that supports php, I could run it just fine by hosting it on the domain using an ftp program like Filezilla.

So this is just a theoretical concept that I'm providing. The contact form that you see below is powered by an external 3rd party php. Its a free gadget that takes input and submits it to a file.

Sample of a Contact form: 

It sends messages to siddhantrimal@hotmail.com


Name *

Email *

Message*



Insider stuff: How is it working?
In the above contact form, the email address is written to a php file in their domain with the help of yet another php file while registration. Then it assigns the generated php file to this code which submits the data to the generated php file in that domain when we click "Send". The php file in that domain then emails the preset recipient(my email address).

 
PHP1-->generates PHP2-->This Form-->Sends data to PHP2-->PHP2 emails.
 

where, 
PHP1-->generates PHP2
happens only ONCE while registration on the host domain.








Taking input and submitting it to a file is done relatively easily with <form>.....</form> tags. In an analogy, it is similar to writing your Username, Email Address and any other information in a sheet of paper much like a form. Then there is the <input> tag which lets users to input data in a form enabling them to 'write' on a form. And finally there's the 'submit' value in 'type' atribute in  input tag i.e <input type="submit"> which lets the user to submit whatever it is written to somewhere else. The destination is mentioned while declaring the form as:
<form name="input" action="FormSub.asp" method="get">
which sends the input data fo Form.Sub.asp file

Similarly, if there is a php file hosted in the domain, it can be sent to that file or even a .txt text file. However, submitting to .php or .asp is beneficial because any third party wont be able to view information from it easily.


So in basic terms, the working mechanisms are:
-Make a form and include submit option
-The form sbumits data to another file

-The recepient file must be a script that can handle input and work accordingly.
-In a php supporting domain, the php is set such that it sends information to a preset email address.
-Hence a mail is sent.

Here's a demonstration on how information is sent from html to another file on the domain. However, this file on the domain WILL NOT send any email because it is not configured to do so. In a personal domain, the user can configure that by simply editing the php file to do task. Phishing sites work in this way.


So, in similar way, another form can be built to glean passwords from victims.
CLICK TO CHECKOUT A SAMPLE PHISHING FORM


Another method of sending emails could be 'mailto'. However, it is quite obsolete these days because it depends on your computers email client like Ms.Outlook Express. If your email client is NOT configured, it wont work at all. And since it is easy to just type http://hotmail.com to check out your email as we are not plagued by slow internet speeds of the dialup era anymore. Email clients were quite useful back at those days because they would store messages offline and messages could load faster than a browser. However that is irrelevant now because browsers load message in a few seconds these days...not much of a need for email clients. Hence they became almost obsolete along with mailto.

If your email client is setup, sending emails is easy as clicking this link

which says: mailto:testmail@domain.com?subject=TEST&body=TESTMSG




  • Facebook Comment
  • Google+
  • Disqus Comment
  • 0Blogger Comment
comments powered by Disqus

Leave your comment

Post a Comment

You don't need ANY account or registration to comment here. Please drop your comments below to improve the quality of our posts. You can also give us suggestions and ask us about your problems.

Flying Bird Widget