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

Username:   Password: 
 RegisterRegister   
 Forms
Index -> Graphics and Design, Web Design -> (X)HTML Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Ravage




PostPosted: 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
Sponsor
sponsor
Blade




PostPosted: 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




PostPosted: 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




PostPosted: Mon Apr 14, 2003 4:51 pm   Post subject: (No subject)

yeah i'm positive... try it out man... i got it up on one of my old sites...
http://members.lycos.co.uk/devilomayhem/stuffs/form.html

edit: sometimes the servers go down... so try it later if you want to
yuethomas




PostPosted: Mon Apr 14, 2003 5:00 pm   Post subject: (No subject)

It isn't much use unless you post the PHP code for us. =p

(Oh and, the script I wrote myself... it doesn't work)

code:
<BODY>
<?PHP
    echo "USING LINE: you entered ".$line."<BR>";
    echo "USING _POST: you entered ".$_POST['line']."<BR>";
?>
<BR><FORM method="post" action="temp.php"><BR>
<INPUT TYPE="text" NAME="line">
<INPUT TYPE="submit">
</FORM></BODY>


It's at http://osiris.dyndns.info/newsite/sections/temp/temp.php.
Blade




PostPosted: Mon Apr 14, 2003 5:25 pm   Post subject: (No subject)

i did post it... thats exactly what i was using up top, i copied and pasted it, ive been doing it that way for a long time man...
yuethomas




PostPosted: Mon Apr 14, 2003 5:27 pm   Post subject: (No subject)

Oy, my bad, didn't realise they were the same thing.

But my script still doesn't work...
Blade




PostPosted: Mon Apr 14, 2003 5:35 pm   Post subject: (No subject)

it works fine on my server
http://members.lycos.co.uk/devilomayhem/stuffs/temp.php
it's probably the way they have their php set up...
Sponsor
Sponsor
Sponsor
sponsor
yuethomas




PostPosted: Mon Apr 14, 2003 5:43 pm   Post subject: (No subject)

Thanks, I'll check my php.ini then.
Blade




PostPosted: Mon Apr 14, 2003 5:44 pm   Post subject: (No subject)

do you have your comp running as a server?
yuethomas




PostPosted: Mon Apr 14, 2003 6:08 pm   Post subject: (No subject)

Yes.
Blade




PostPosted: Mon Apr 14, 2003 6:20 pm   Post subject: (No subject)

sweet... i'd like to ask you a couple question... do you have msn or aim?
octopi




PostPosted: Mon Apr 14, 2003 7:52 pm   Post subject: (No subject)

Now, since the OP mentioned not using cgi script (which php, perl, c++ etc.. are.(when used over the internet))

code:
<form action="mailto:somedude@thisplace.com" method="POST" enctype="text/plain">


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.

http://www.scriptarchive.com/formmail.html

You will need perl installed to use it(on your server), but if you search on google you can find versions for php etc..

http://www.google.ca/search?q=formmail+php
Blade




PostPosted: Mon Apr 14, 2003 8:17 pm   Post subject: (No subject)

perl is cgi... php isn't anything like perl
octopi




PostPosted: Mon Apr 14, 2003 8:35 pm   Post subject: (No subject)

Your correct, one could also say that perl and c++ are not alike, but both can, and are used as 'cgi scripts'.

Php is more commonly used like mod_perl is, which runs as a module linked into apache (or whatever major webserver you use.)

However you can use php in the exact same way you would call perl (and originally had to).

code:
#!/usr/bin/php


code:
#!/usr/bin/perl


both those assume a unix machine (with perl, and php installed into /usr/bin)
you can then follow with php code, the exact same you would with perl.
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 2  [ 19 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: