Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 registration forms
Index -> Graphics and Design, Web Design -> (X)HTML Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Linux




PostPosted: Sat Apr 09, 2005 6:55 pm   Post subject: registration forms

i have read some of the posts for forms, but i would like to kno how exactly i would make a form that i could use on my website, i have a good idea how to make a form, now how would i make it send its self to my email address? i dont want to use mailto: i want the forms to be sent to me to my email on the server.

would i have to make a cgi script?

how would i make a cgi script and can someone show me a script for this kind of thing and how it works, or maby write a tutorial for making cgi scripts.

thank you
Sponsor
Sponsor
Sponsor
sponsor
Blade




PostPosted: Sun Apr 10, 2005 10:24 am   Post subject: (No subject)

you can use php for that too.. uhm, i'll make an example form you can use just to send your name to your email address, you can add more onto it later if you want to.. a good reference for form elements is www.webmonkey.com
I will post a much more detailed one that i wrote up yesturday when i get home.
HTML:
<form method="post" action="handler.php">
Name:<input type="text" name="name">
<br><br>
<input type="submit">

but, remember, the server you use must have sendmail installed for php to be able to send emails.
php:
//handler.php
mail("youremail@emails.com", "Your Subject", "Hi, you entered\n" . $_POST['name'] . "\nas your name") or die("Failed to send message");

I can't explain too much right now, but i'll post a much more detailed form and form handler with comments later.
Blade




PostPosted: Sun Apr 10, 2005 11:40 am   Post subject: (No subject)

Okay, well i got that file..

HTML:
<!-- form_example.html -->

<!-- this is what a comment looks like -->

<form method="post" action="form_handler_example.php"> <!-- i'm sure you know what this line is -->
  Some Text:<br>
  <input type="text" name="stext"> <-- stext will be the name of the variable in php when the form is passed -->
  Select Example:<br>
  <select name="selex"> <!-- like a text field, names are used -->
    <option value="www.yahoo.com">yahoo</option> <!-- in select menus, the value is what is passed, so if you choose Yahoo, selex=www.yahoo.com -->
    <option value="www.google.com">Google</option>
    <option value="www.altavista.com">AltaVista</option>
  </select>
  <br>
  Radio Button Example:<br>
  <input type="radio" name="radexample" value="www.hotmail.com" selected>Hotmail<br> <!-- in a list of radio buttons, they all have the same name but different values -->
  <input type="radio" name="radexample" value="www.yahoo.com">Yahoo<br>
  <input type="radio" name="radexample" value="www.google.com/gmail">Gmail<br>
  Textarea Example:<br>
  <textarea name="textex"></textarea>
  <br>
  <br>
  <input type="submit">
</form>

<!-- end form_example.html -->

I dont know how much you know about programming, but i try to explain most of whats going on. if you dont understand, maybe you should start with the basics
php:

<?
  // form_handler_example.php
  // <-- are comments

  //just as an example, you can do certian checks on the form with php to determine whether or not it is in your range of expectations
  //with that, we'll check to see if the user left the 'Some Text' field blank or not
  if($_POST['stext'] == ""){
    die("You must fill in \"Some Text\""); //die makes php stop executing the script and returns whatever is between the parenthesis ()
  }

  //iam not going to put checks in for all of them because you can use that as an example

  mail("youremail@emails.com", "Your Subject", "Hi, you entered\n'" . $_POST['stext'] . "', '" . $_POST['selex'] . "', '" . $_POST['radexample'] . "','" . $_POST['textex'] . "'") or die("Failed to send message");
  //in the above line.. because you are using an array of values that was passed from the form
  //you must 'concatenate' (which means to join) the value from the array into the rest of it..
?> 
wtd




PostPosted: Sun Apr 10, 2005 2:12 pm   Post subject: (No subject)

Blade wrote:
I dont know how much you know about programming, but i try to explain most of whats going on. if you dont understand, maybe you should start with the basics


We have a winner!
Blade




PostPosted: Sun Apr 10, 2005 3:10 pm   Post subject: (No subject)

wtd, you would be surprised at the questions i get while teaching this stuff.. this would be pointing out the obvious in both mine and your eyes because we're experienced programmers. but the obvious to new people is not the same obvious as us. little things that you expect people to know, they may not know.. so you have to point it out for them, no matter how stupid it sounds.. thats what makes a good teacher. i guess ti could be insulting to some people, but when you're trying to help someone and you dont know how experienced they are, usually assuming the lowest amount of experience judging by their post is the best bet
wtd




PostPosted: Sun Apr 10, 2005 6:19 pm   Post subject: (No subject)

It seems a decent enough approach is the binary search method. Start assuming a medium level of knowledge, then if that's too advanced, back off, and if it's too low-level, work on something more advanced.
Display posts from previous:   
   Index -> Graphics and Design, Web Design -> (X)HTML Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: