Help with creating Movies Database

Discussion in 'Perl Misc' started by TP, Feb 1, 2004.

  1. TP

    TP Guest

    hi
    this is my HTML page for the movie database
    http://web.ics.purdue.edu/~tkhor/newdata.html

    i get the function for search and list all movies to work but i dont get the
    Add movies to work.
    this is my source code for my cgi script

    sub addrecord {
    $NameText = $form{'NameText'};
    $moviedescription = $form{'moviedescription'};
    $moviecast = $form {'moviecast'};

    $NameText=~s/</\&lt;/g;
    $moviedescription=~s/</\&lt;/g;
    $moviecast=~s/</\&lt;/g;

    &open_file("FILE1",">>",$filename);

    &write_file("FILE1",$NameText."|".$moviedescription."|".$moviecast."\n");
    close(FILE1);

    print"Content-type:text/html\n\n";
    print"<html><head><title>Thank You </title></head>\n";
    print "<body><br><h3><center>Thank you for adding
    information</center></h3>\n";
    print "<p>";
    print"</body></html>\n";
    exit;
    }

    * how should i modify the code so that i make it work?
    * when i click on the show all function on the webpage , it seem that i wont
    list the MOvie description ... so how can i fix this....

    i am a newbie here with perl and cgi..so any help will highly
    appreciate!!!!!!!!

    thanks
     
    TP, Feb 1, 2004
    #1
    1. Advertising

  2. TP

    Matt Garrish Guest

    "TP" <> wrote in message
    news:bvjv9b$fbs$...
    >
    > * how should i modify the code so that i make it work?
    >


    Ask whoever wrote that awful code how to fix it. This isn't a helpdesk for
    buggy code you found on the Web.

    Matt
     
    Matt Garrish, Feb 1, 2004
    #2
    1. Advertising

  3. TP <> wrote:

    > this is my source code for my cgi script



    Are you using the CGI.pm module for decoding the form input?

    You should have this near the top of your program, at least
    during development:

    #!/usr/bin/perl -T
    use strict;
    use warnings;
    use CGI::Carp qw(fatalsToBrowser);


    Each of those will help you write correct and secure programs.

    Ask for all of the (machine) help you can get!


    > $NameText=~s/</\&lt;/g;
    > $moviedescription=~s/</\&lt;/g;
    > $moviecast=~s/</\&lt;/g;



    Ampersand is not special in regexes, so you don't need to backslash it.

    Whitespace is not a scarce resource, feel free to use as much as you
    like to make your code easier to read and understand.

    No need to write the same code three times, write it once,
    and loop over it three times instead:

    foreach ( $NameText, $moviedescription, $moviecast ) {
    s/</&lt;/g;
    }

    (there are other characters that may need escaping you know...)


    > &open_file("FILE1",">>",$filename);



    Don't use the ampersand on function calls unless you know what it
    does, and what it does is what you want (it seldom is what you want).

    You should always, yes *always*, check the return value from open():

    open_file("FILE1", ">>", $filename) or
    die "could not open '$filename' $!";


    > &write_file("FILE1",$NameText."|".$moviedescription."|".$moviecast."\n");


    write_file('FILE1', join '|', $NameText, $moviedescription, "$moviecast\n";


    > i am a newbie here with perl and cgi..so any help will highly
    > appreciate!!!!!!!!



    Have you seen the Perl FAQs that deal with CGI and HTML?


    perldoc -q CGI

    Where can I learn about CGI or Web programming in Perl?

    What is the correct form of response from a CGI script?

    My CGI script runs from the command line but not the browser. (500
    Server Error)

    How can I get better error messages from a CGI program?

    How do I make sure users can't enter values into a form that cause my
    CGI script to do bad things?

    How do I decode a CGI form?


    perldoc -q HTML

    How do I remove HTML from a string?

    How do I fetch an HTML file?

    How do I automate an HTML form submission?



    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Feb 1, 2004
    #3
  4. Also sprach Tad McClellan:

    > TP <> wrote:


    >> &open_file("FILE1",">>",$filename);

    >
    >
    > Don't use the ampersand on function calls unless you know what it
    > does, and what it does is what you want (it seldom is what you want).
    >
    > You should always, yes *always*, check the return value from open():
    >
    > open_file("FILE1", ">>", $filename) or
    > die "could not open '$filename' $!";


    That applies to open(), but what is open_file()?

    When looking at this sequence:

    &open_file("FILE1",">>",$filename);
    write_file('FILE1', join '|', $NameText, $moviedescription,"$moviecast\n";
    close FILE1;

    I get pain in my stomach. In the first two lines, "FILE1" is used as a
    string, while in the last line it is used as a filehandle. This can only
    work if the filehandle is created in open_file() through a symbolic
    reference or so.

    We need to see the code of open_file() and write_file().

    Tassilo
    --
    $_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
    pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
    $_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
     
    Tassilo v. Parseval, Feb 2, 2004
    #4
  5. TP

    gnari Guest

    "Tassilo v. Parseval" <> wrote in message
    news:bvkqnk$53l$-Aachen.DE...
    > Also sprach Tad McClellan:
    > When looking at this sequence:
    >
    > &open_file("FILE1",">>",$filename);
    > write_file('FILE1', join '|', $NameText,

    $moviedescription,"$moviecast\n";
    > close FILE1;
    >
    > I get pain in my stomach. In the first two lines, "FILE1" is used as a
    > string, while in the last line it is used as a filehandle. This can only
    > work if the filehandle is created in open_file() through a symbolic
    > reference or so.
    >
    > We need to see the code of open_file() and write_file().


    no, I think we actually do not need to see that

    I would much rather help the OP with some of his own code.

    gnari
     
    gnari, Feb 2, 2004
    #5
  6. Also sprach gnari:

    > "Tassilo v. Parseval" <> wrote in message
    > news:bvkqnk$53l$-Aachen.DE...
    >> Also sprach Tad McClellan:
    >> When looking at this sequence:
    >>
    >> &open_file("FILE1",">>",$filename);
    >> write_file('FILE1', join '|', $NameText,

    > $moviedescription,"$moviecast\n";
    >> close FILE1;
    >>
    >> I get pain in my stomach. In the first two lines, "FILE1" is used as a
    >> string, while in the last line it is used as a filehandle. This can only
    >> work if the filehandle is created in open_file() through a symbolic
    >> reference or so.
    >>
    >> We need to see the code of open_file() and write_file().

    >
    > no, I think we actually do not need to see that
    >
    > I would much rather help the OP with some of his own code.


    There were no use() or require() statements in the code he posted, so I
    assume that these are functions defined by him.

    Tassilo
    --
    $_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
    pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
    $_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
     
    Tassilo v. Parseval, Feb 2, 2004
    #6
  7. TP

    gnari Guest

    "Tassilo v. Parseval" <> wrote in message
    news:bvmb2i$9nh$-Aachen.DE...
    > Also sprach gnari:
    >
    > >> We need to see the code of open_file() and write_file().

    > >
    > > no, I think we actually do not need to see that
    > >
    > > I would much rather help the OP with some of his own code.

    >
    > There were no use() or require() statements in the code he posted, so I
    > assume that these are functions defined by him.


    well,
    a) this was obviously not a complete program.
    b) the way he said 'modify the code' somehow suggested to me that the code
    was felched from the net. (I used the admittedly buggy ESP module for that)
    c) if it was his own code, he would have realized that he was not posting
    the
    most critical part, namely the open_file() and write_file() subs.

    I think you give the OP to much benefit of doubt.

    gnari
     
    gnari, Feb 2, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Will
    Replies:
    0
    Views:
    1,934
  2. movies

    , May 12, 2005, in forum: Java
    Replies:
    1
    Views:
    453
    ted holden
    May 12, 2005
  3. Ross Clement (Email address invalid - do not use)

    Create movies in Java

    Ross Clement (Email address invalid - do not use), Jan 1, 2006, in forum: Java
    Replies:
    13
    Views:
    18,050
    digithree
    Feb 8, 2012
  4. EightNineThree
    Replies:
    3
    Views:
    433
    Whitecrest
    Aug 24, 2003
  5. Mel Smith
    Replies:
    7
    Views:
    458
    Neredbojias
    Aug 26, 2009
Loading...

Share This Page