Jump to content

Forms/form handling


Recommended Posts

Hello, I am new to these forums so if this is posted wrongly, I apologise in advance.


So I have been trying my hand at forms. I can figure out how to make nice forms, but the problem is, if I cannot do form handling, what is the point? I have been trying to work on a form that auto sends to a email address, and preferably a excel spreadsheet if it wasn't to difficult, I don't really care about validiation, it is not going to be a wildly used form, so I would be happy to do it manually. Mailto opens a email client, and is not the most secure so I have ruled that out. I have been trying to do this for a while, spending multiple hours on it.If someone could help, it would make my day. I want it to be very simple, the format is not really an issue, if someone could answer some questions, and provide some input, it would be the best.

What is the best way to do it?( javascript, python, ruby,php)

Do you know of any good sites that have some useful information?(trust me, I have looked at a lot of sites, but I would be happy to look at more.)

Any other suggestions?


Probably my biggest problem is I am new to this, and my form is a bit advanced, but like I said help, any help would be appreciated.

Here is the code for reference( I have kept it simple to simplify things)


Thanks a lot for reading my post and with my simple questions

FormTest (2).html

Edited by wdsurvey
Link to comment
Share on other sites

Well, this is untested -- but maybe something like this...



<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Survey Form</title></head><body><h1>Welcome!</h1><p>Welcome to our survey! Please note your first name and class are not stored and are in place for verification purposes! It doesn't matter to us who you are, but that you attend, and only fill this out once! Thanks for participating!</p><form action="sendmail.php" method="post"><fieldset><legend>Demographics</legend>First Name: <input type="text" name="name"><br/>Tag Class: <input type ="text" name="tag"><br/></fieldset><fieldset><legend>Social Media</legend><label>Selects which you have:</label><br/>Facebook:<input type="checkbox" name="FB" value="FB"/><br/>Twitter: <input type="checkbox" name="TWEET" value="TWEET"/><br/>Instagram:<input type="checkbox" name="INSTA" value="INSTA"/><br/>Pinterest:<input type="checkbox" name="PIN" value="PIN"/><br/>Flicker:<input type="checkbox" name="FLICK" value="FLICK"/><br/>LinkedIn:<input type="checkbox" name="LINK" value="LINK"/><br/>MySpace:<input type="checkbox" name="MSPACE" value="MSPACE"/><br/>Which is your most used?<select id="social" name="social">                <option value="-" selected>--</option>		<option value="FB">Facebook</option>		<option value="TWIT">Twitter</option>		<option value="INST">Instagram</option>		<option value="PIN">Pinterest</option>		<option value="FLICK">Flicker</option>		<option value="LINK">LinkedIn</option>		<option value="MSPACE">MySpace</option>		</select>			<br/> How much do you use this most used?<select id="rate" name="rate">                <option value="-" selected>--</option>		<option value="10+/day">10+ times per day</option>		<option value="8-9/day">8-9 times per day</option>		<option value="6-7/day">6-7 times per day</option>		<option value="4-5/day">4-5 times per day</option>		<option value="2-3/day">2-3 times per day</option>		<option value="1/day">Once a day</option>		<option value="3-6/wk">3-6 times per week</option>		<option value="1-3/wk">1-3 times per week</option>		<option value="rarely">rarely</option><br/></select><br/><input type="submit" value="Submit"/></form></body></html>

sendmail.php file...

<!DOCTYPE html><html><head><meta charset="utf-8"><title>send mail</title></head><body><?php$valid = true;$str = '';if (isset($_POST["name"])) {  $name = filter_var($_POST["name"], FILTER_SANITIZE_EMAIL);  if ($name==false) {     $valid = false;  }else{     $str .= 'Name= ' .$name. 'n';  }}else{  $valid = false;}if (isset($_POST["tag"])) {  $tag = filter_var($_POST["tag"], FILTER_SANITIZE_EMAIL);  if ($tag==false) {     $valid = false;  }else{     $str .= 'Tag= ' .$tag. 'n';  }}else{  $valid = false;}if (isset($_POST["FB"])) {     $str .= 'Facebook= truen';  }}if (isset($_POST["TWEET"])) {     $str .= 'Twitter= truen';  }}if (isset($_POST["INSTA"])) {     $str .= 'Instagram= truen';  }}if (isset($_POST["PIN"])) {     $str .= 'Pinterest= truen';  }}if (isset($_POST["FLICK"])) {     $str .= 'Flicker= truen';  }}if (isset($_POST["LINK"])) {     $str .= 'Linkedin= truen';  }}if (isset($_POST["MSPACE"])) {     $str .= 'MySpace= truen';  }}if (isset($_POST["social"])) {  $social = filter_var($_POST["social"], FILTER_SANITIZE_EMAIL);  if ($social==false||$social=='-') {     $valid = false;  }else{     $str .= 'Social= ' .$social. 'n';  }}if (isset($_POST["rate"])) {  $rate = filter_var($_POST["rate"], FILTER_SANITIZE_EMAIL);  if ($rate==false||$rate=='-') {     $valid = false;  }else{     $str .= 'Rate= ' .$rate. 'n';  }}if ($valid){  $subject = 'Feedback form';  mail("webmaster@example.com", $subject, $str, "From: Feedback_Formn");  echo "Thank you for sending us feedback";}else{  echo "Error: invalid input";}     ?><br/><br/><a href="FormTest.html">GO BACK to Survey Form</a></body></html>
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...