Posted: Mon Apr 14, 2003 12:13 pm Post subject: Forms
I was wondering if there is anyway to make a form without using CGI script (I know this isnt HTML but I dont know where else to put it)
Sponsor Sponsor
Blade
Posted: Mon Apr 14, 2003 12:26 pm Post subject: (No subject)
you have to use some sort of scripting language... i prefer to use php, so heres an example..
code:
<html>
<form method=post action=accept.php>
Enter your name:<br>
<input type=text name=name><br>
Enter your age:<br>
<input type=text name=age><br>
Select one:<br>
<select name=sel>
<option>Girl
<option>Boy
<option>Man
<option>Woman
<option>I don't know
</select><br>
<input type=submit>
</form>
</html>
that is what a form may look like... and a form handler in php would look like this... although you will have to find a server that has php to be able to execute it.. but anyway, here it is
code:
// name this accept.php so the form can find it
// also put it in the same folder..
<?
echo "Your name is $name<br>";
echo "Your age is $age<br>";
echo "And you are a $sel";
?>
the <? ?> tags are to show that you are starting up the php parser, echo is used to output to the screeen, and if you wanted different things posted you'd use a large if statement, or an array with a while loop. php is much like C++ like its if statements, the semicolon at the end of each line, and so on... although the variables are shows with $'s...
edit:
i would also lke to add that another really good thing about php is you can start it anywhere in an html document, and then end it, and use html for a while... even when you have php running in the document you can unlude tags using echo() like i did in my example of the form handler
yuethomas
Posted: Mon Apr 14, 2003 4:44 pm Post subject: (No subject)
Err, are you sure about the variables' names in PHP part? I remember you have to use $_POST['name'], $_POST['age'], etc. The method=get equivalents are $_GET['name'], $_GET['age'], etc.
Blade
Posted: Mon Apr 14, 2003 4:51 pm Post subject: (No subject)
That will send the form contents to your email address, downside is it uses outlook to send the form, and IE pops up a bunch of warning messages about it.
A much better solution would be to use formmail.pl by Matt Wright.