Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Database ?

Options
  • 13-02-2001 8:49pm
    #1
    Closed Accounts Posts: 43


    OK,

    I'm not too familiar with either PHP, ASP, XML or any of these databasing script languages .. but what I need to do is the following:

    Create a form-like database that when people chose certain things their choice is assigned a variable, and then when all their choices are selected, the results can be inputed in a page where the variable is replaced by their choice ...

    ..<input type="radio" name="%" value="£">
    ..<input type="radio" name="%" value="$">

    %=choice
    £=mars
    $=snickers

    Then it goes to a page and thats something like:

    ..<font size="2">Your choice of % is a poor choice</font>

    Appears like

    ... Your choice of Mars is a poor choice.

    very **** example I know but what's the easiest and best way to implement this, remembering I've no real experience with any of these languages ... but learn fast! smile.gif


Comments

  • Registered Users Posts: 4,276 ✭✭✭damnyanks


    Learn coldfusion its a joke how easy it is 100 lines of cfm and u have a good content script up and running with logins auto insert auto display and ssi



  • Registered Users Posts: 707 ✭✭✭d4r3n


    this is what u want done in perl
    is this ur homework or something? lol

    #!/usr/bin/perl

    &parse_form;

    if ($data{'action'} eq "")
    {
    print "Content-type: text/html\n\n";
    print "<html>";
    print "<head>";
    print "<title>FuNk</title>";
    print "</head>";
    print "<form method=\"POST\" action=\"this-script.cgi\">";
    print "<p>pick a bar:</p>";
    print "Mars";
    print "<input type=\"radio\" name=\"bar\" value=\"mars\"><br>";
    print "Snickers";
    print "<input type=\"radio\" name=\"bar\" value=\"snickers\">";
    print "<p>";
    print "<input type=\"hidden\" name=\"action\" value=\"check-it\">";
    print "<input type=\"submit\" name=\"Submit\" value=\"y0y0y0y0\">";
    print "</p>";
    print "</form>";
    print "</body>";
    print "</html>";
    }
    else
    {
    print "Content-type: text/html\n\n";
    print "your choice of $data{'bar'} is a poor choice";
    }

    sub parse_form
    {
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    @pairs = split(/&/, $buffer);
    foreach $pair (@pairs)
    {
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%(..)/pack("C", hex($1))/eg;
    $data{$name} = $value;
    }
    }


    [This message has been edited by d4r3n (edited 13-02-2001).]


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    Jaysus d4r3n! Haven't you heard of CGI.pm!? use it man! wink.gif

    Here it is using CGI.pm
    #!/usr/bin/perl -w
    use CGI qw/:all/;
    use strict;
    
    my $cgi    = CGI-&gt;new();
    my $choice = $cgi-&gt;param('choice');
    
    if ($choice)
    {
       print header, start_html(-BGCOLOR =&gt; '#FFFFFF');
       print p("Your choice of ", $choice " was a poor one");
       print end_html;
    
    }
    else
    {
       print header, start_html(-BGCOLOR =&gt; '#FFFFFF');
       print start_form;
       print &lt;&lt;RADIO_BUTTONS;
       Mars &lt;input type="radio" name="choice" value="mars"&gt;&lt;br&gt;
       Snickers &lt;input type="radio" name="choice" value="snickers"&gt;
    RADIO_BUTTONS;
       print p(submit, reset);
       print end_form;
       print end_html; 
    }
    
    
    That should do it.

    Perl is pretty easy to use and well handy for other things apart from CGI scripts.
    You should also take a look at JSP, it's fast, easy oh and it's Java smile.gif



  • Closed Accounts Posts: 6,601 ✭✭✭Kali


    i havent done any php stuff in ages but...

    form.php3:

    <FORM NAME="test" ACTION="result.php3" METHOD="post">
    <INPUT TYPE=text SIZE=8 NAME=choice1>
    </FORM>

    result.php3:

    <HTML><BODY>choice one is: <? print $choice1 ?></BODY></HTML>

    note i couldnt be arsed checking this or doing radio form elements like you asked.. use your head smile.gif

    PHP is so much easier for little things like this than using perl or any of its extra CGI modules (CGI.pm) although they make the job of maintaining some control a lot better.
    either way having to have your html within perl files and in a non-html format is awfully constrictive.


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    PHP is definetely easier for little things like this but when a project grow and becomes more complex you've got logic (PHP) and display (HTML) code all in the one file.

    With Perl you can at least outsource the HTML to a template file.

    The best way to get around this problem though, would be to use XML & XSL. Java is great at this kind of thing.

    BTW, has anyone here looked at Jive? http://www.coolservlets.com/jive
    It's a message board similar to UBB but it's in Java. It's got a whole bunch of custom tags so you can create any style of board you like. And they're working on XSL type skins. Cool.


  • Advertisement
  • Registered Users Posts: 4,276 ✭✭✭damnyanks


    or like i said goto coldfusion its just like html but harder to find hosts for it, a free one is www.cfm-resources.com, by using cfquery a sql statment you can display a database thats like 4 lines of text, if you wanna input turn cfquery into cfinsert and tehre you go


  • Closed Accounts Posts: 43 nard


    cheers for the many replies ...

    I think Coldfusion might be a good choice as I've a somewhat limited experience using Coldfucion Studio ... but is there any place online or what not that gives a quick tutorial, because I shurely don't want to lower myself and actually buy a book to teach me it...

    Basically I wanna pick one database language that I can use for webpages, learn it, and use it.

    What's my best option ?


  • Registered Users Posts: 1,481 ✭✭✭satchmo


    I'd go for Coldfusion. It's **** easy. Check out www.webmonkey.com for tutorials.


  • Registered Users Posts: 932 ✭✭✭yossarin


    ColdFusion needs a licence. an expensive one.

    If you're starting from stratch you'd seem to be better with somthing like php.

    how extensive is this going to be ?


  • Registered Users Posts: 4,276 ✭✭✭damnyanks


    http://www.sitepoint.com has tutorials on cfm havent looked at them but they normaly have good stuff at that site, if your going to buy cold fusion yes it will be expensive but no one would do that if starting out like i said, cfm-resources.com is a free host so it will cost him nothing smile.gif


  • Advertisement
Advertisement