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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PERL help

  • 16-04-2003 7:31pm
    #1
    Registered Users, Registered Users 2 Posts: 605 ✭✭✭


    Hey,
    it's not a major deal or anything because the script is just for my personal homepage but I'v been using a guestbook script in perl for about a year now.
    There's nothing wrong with the script afaik, but the server where I host it for somereason executes the script once or twice every day and the script posts blanks into the guestbook.
    I'm just wondering how can I edit the script so it will just generate an error if the input fields are blank?

    I'v attatched the script with this post.


    Thanks a million.


Comments

  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    Have a look for some javascript to do with validating form input. It's a far cry from ensuring that no-one would ever enter blanks, but for a guestbook, it's plenty.

    :)


  • Registered Users, Registered Users 2 Posts: 605 ✭✭✭exiztone


    Nah that wouldn't work for me because the problem isn't in the form itself. The server executes the script without the form at random times and the script just assumes it's coming from the form with nothing in it and in turn posts blanks. :(


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    Em....well my code may be a complete bastardisation/hybrid of PHP, Perl, and Java but if put something like:
    $validEntry = 1;
    foreach ($data as $value) {
              if ($value == '') 
                  $validEntry = 0;
    }
    

    Then put an if statement around the section where it writes to the file:

    if ($validEntry) {
    //Write to file
    }



    Ifyou get my drift....


  • Registered Users, Registered Users 2 Posts: 605 ✭✭✭exiztone


    Hey,
    nah man, it just gave an internal server error with that.
    I think I put it in correctly anyway.

    Is it right?


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    Heh, yeah that's the right idea, but my little bit of code there isn't Perl, it's just my attempt to get the idea across :)

    Maybe someone who knows Perl properly could rewrite my code to do it?

    :)


  • Advertisement
  • Closed Accounts Posts: 286 ✭✭Kev


    try something like

    ( defined($formdata) && ($formdata ne '') ) or die;

    after this

    $formdata=<STDIN>;
    $formdata=~s/\s+$//;


  • Registered Users, Registered Users 2 Posts: 605 ✭✭✭exiztone


    Hmmm no, that doesn't seem to work either :confused:


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


    Warning: It's been almost 2 years since I've written any Perl.

    You should at least get the drift here:


  • Registered Users, Registered Users 2 Posts: 605 ✭✭✭exiztone


    Man, it works like a charm!
    Thanks very much! :D


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


    Still got it baby! Woohoo! :D


  • Advertisement
Advertisement