Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2003
    Posts
    3

    Unanswered: How2 use a web form to update database?

    Hi!
    I have a few local webforms that is supposed to update the MySQL database. I have an Apache server running locally. When using Oracle9i I need to set up a DAD that tells the system where to find the database and which ports to pass through.
    How can I make the information in the webforms reach the MySQL-base?
    Are there "DAD:s" in this environment too?

    Appreciate any help!
    Thanks in advance!

    /Morgan

  2. #2
    Join Date
    Nov 2003
    Location
    Sinapore
    Posts
    187
    You could use a programming language like perl (Perl:BI) to access the data in my MySQL. You can then perform any sort of queries from the web interface like you would do from mysql command line.

    Since you already have Apache running, if you know php or perl, it should not be too difficult to use either one of them to connect to the database and have information from say a web form reach the database.

  3. #3
    Join Date
    Dec 2003
    Posts
    3
    Thank you for your thought! I run MySQL at an WinXP Pro computer today (will move it to Win 2003 soon). Can I run Perl at them too? How can I make the webforms "find" the database? w. Oracle I use an URL like "http://localhost/pls/scott/..." (or an alias) to access it. I have used Perl at Unix computers earlier and I found that environment much easier to use but right now I'm stuck with Windows. Could you help me in the Windows environment? Rgds/Morgan
    Originally posted by pearl2
    You could use a programming language like perl (Perl:BI) to access the data in my MySQL. You can then perform any sort of queries from the web interface like you would do from mysql command line.

    Since you already have Apache running, if you know php or perl, it should not be too difficult to use either one of them to connect to the database and have information from say a web form reach the database.

  4. #4
    Join Date
    Nov 2003
    Location
    Sinapore
    Posts
    187
    I'm using Windows 98. I've perl 5.8 installed in C:\perl5.8, mysql installed in C\mysql (the default directory) and apache installed in C:\apahce2.

    I create my databases via mysql command line. I don't know how others do it but I've pre-made sql statements saved in C:\myslq\bin. I then start mysql and at the command line:

    mysql> source name_of_sql_file

    ( 'source' is the command to input the saved sql statements )

    An example of such a file is as follows;

    DROP TABLE IF EXISTS levels;
    CREATE TABLE levels (
    level_id CHAR(1)NOT NULL PRIMARY KEY,
    level VARCHAR(15) NOT NULL,
    );

    I do the same with insert statements. That saves the trouble of typing out the statements at the mysql prompt.

    In my perl scripts, I've the shebang line as follows:

    #!C:/perl5.8/bin/perl.exe

    Used with apache, this tells the script where to look for the perl interpreter. Provided you've configured the apache config file, perl scripts will execute when called from the browser e.g.

    http://127.0.0.1/myscript.pl

    These are the things in you need to look out for in the apache config file:

    1) # DocumentRoot "C:/apache/Apache2/htdocs"
    -> Change this to your web directory

    2) #<Directory />
    # Options Indexes FollowSymLinks
    # AllowOverride None
    #</Directory>

    3) #<Directory "C:/apache/Apache2/htdocs">
    -> Change this to your web directory

    4) #Options Indexes FollowSymLinks
    -> Options Indexes FollowSymLinks MultiViews ExecCGI Includes

    5) AllowOverride None
    -> Change to AllowOverride All

    6) #AddHandler cgi-script .cgi
    -> Change to AddHandler cgi-script .pl
    ( To allow perl scripts to run with .pl extension)

    Assuming both mysql and apache are running, you establish a connection to the database via the perl script (the variables you need to know: the database driver, the username, password, and the name of the database). There are lots of tutorials on the web on how to do that.

    The databases you've created reside in C:\mysql\data. You need not worry about how to find the databases. Once a connection via the perl script is established, your database will be automatically accessible to your program.

    It may be a bit messy the way I've described but I hope it'll give you some idea.

  5. #5
    Join Date
    Dec 2003
    Posts
    1

    Lightbulb

    Originally posted by DBhacket
    Thank you for your thought! I run MySQL at an WinXP Pro computer today (will move it to Win 2003 soon). Can I run Perl at them too? How can I make the webforms "find" the database? w. Oracle I use an URL like "http://localhost/pls/scott/..." (or an alias) to access it. I have used Perl at Unix computers earlier and I found that environment much easier to use but right now I'm stuck with Windows. Could you help me in the Windows environment? Rgds/Morgan
    You will run your Perl or PHP script like this:
    http://localhost/cgi-bin/yourscript.cgi

    or from another web page:
    METHOD=POST ACTION="http://localhost/cgi-bin/yourscript.cgi"

    Your script will contact Mysql then.
    If you install Perl you will need a couple of modules in your Perl library:
    DBI.pm and DBD::mysql
    http://search.cpan.org/author/TIMB
    http://search.cpan.org/author/JWIED

    Download a script:
    http://www.mysqldatamanager.com/prod...nloads/mdm.zip

    and see how it works.

  6. #6
    Join Date
    Oct 2003
    Posts
    706

    Exclamation

    The thing to remember is that each server or computer has its own distinct role (even if they're the same computer):

    (1) Your workstation is the "client." All it does is run a browser; any browser.

    (2) The computer that's running Apache is the web-server, which sits around delivering web pages all day. It also runs Perl, PHP, or whatever programming language you're using.

    (3) The database server takes SQL queries, from any source, and delivers result-sets, and executes SQL commands.

    Also, there are plenty of existing web-pages out there in source-code form for the basic purpose of "updating a database." You don't have to start from scratch; don't have to reinvent the wheel. Make sure that you don't.
    ChimneySweep(R): fast, automatic
    table repair at a click of the
    mouse! http://www.sundialservices.com

  7. #7
    Join Date
    Jan 2004
    Location
    NC
    Posts
    1

    Lightbulb Thanks for getting more to the point

    I was glad to see somebody addressed the real question on this post, lol. This person wants to know how to connect to his db via web form.

    My first question would be which scripting language he was using to access the db from within the form.

    IF he is using PHP then....................
    He needs to put the appropriate db connect info in the form or create a script for that info and include it. He can find that basic script info at any PHP website or open source(sourceforge.net is great for this) package downloadable zip file.

    IF it's PERL..............
    I have no clue, lol. I haven't had much luck with Perl and CGI so I moved gracefully on to php/MySQL lol.

    It's also worth noting here that there are MANY FREE packages now that various people have put together that make installing all these different programs a real breeze. I use XAMPP which is VERY easy to install all you need to get your own server and website up and going.

    I can't imagine even bothering with command line code, lol. I'm a newby at all of this stuff but oh my gosh. I used phpmyadmin to set up my database in no time flat. I use every tool I can find to keep from doing hard code if I don't have to. I was broke in on 4th and 5th generation Report Writer programming languages(what a mouthful, lol). I'm spoiled rotten! LOL I love "copy/paste" method, omg :-).

    vvgl2u!

  8. #8
    Join Date
    Dec 2003
    Posts
    3

    Thumbs up Re:How2 use a web form to update database?

    Hi guys!
    Many thanks for your help answering my questions!
    I will take your notes and study more in detail but from the first short look, so far it looks great.
    Rgds,
    /Morgan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •