Jump to content

How to create form in webbsite to collect message from visitor


dinesh101

Recommended Posts

I want to include a form in my website for visitors to enter there name, email and message. I have yet not learnt how to do it so i am looking for help...If sending form data to an email is too complicated, I dont mind having a system in which the form data is written on to a file in my server directory. Eg: a note which i can read manully.

Link to comment
Share on other sites

This will get you started http://www.w3schools...hp/php_mail.asp It's pretty easy, but let us know if you need help. Please notice that the link is for a php function. I suggest the php/sql route before trying to add javascript top the mix.

Edited by niche
Link to comment
Share on other sites

Your form needs an action attribute of a specified file which will deal with the submitted data.

 <form action="some_file.php" method="POST">   <fieldset>   <legend>Comment Form</legend>      <p><label for="name">Name:</label><input type="text" id="name" name="name" /></p>      <p><label for="email">Email:</label><input type="text" id="email" name="email" /></p>      <p><label for="comment">Comment:</label><textarea name="comment" rows="5" cols="30"></textarea></p>      <p><input type="submit" name="submit" value="Send Comment" /><input type="reset" name="reset" value="Clear" /></p>   </fieldset></form>

PHP script:

$name = $_POST['name'];$email = $_POST['email'];$comment = $_POST['comment'];

etc. There is more validation to be done before sending the email. Give niche's link a read. Regards, Labtec.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...