Okay, let's see if we can apply the advice in the various replies, and then maybe (finally) you will understand what everyone else is talking about.

Your code should look like this -- notice how it begins with the logic that checks the parameters:

#!/usr/bin/perl use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); use CGI qw(:standard); use DBD::mysql; use POSIX qw(strftime); my @param_errors = (); my $dbh = DBI->connect('DBI:mysql:nikos_db', 'root', 'password', {Rais +eError=>1}); if ( param( 'Σύνδεση' )) { # user +hit the "login" button # check that username, password and email are filled in, # query database to see if these values are okay ... # if login is okay, redirect and exit # otherwise, push an error message onto @param_errors } elsif ( param( 'Εγγραφή' )) { # us +er hit "new user" button # check whether all necessary params are present, # query database to see if user-supplied username has been used .. +. # if okay, insert new user record into database, redirect and exit # otherwise, push error message(s) onto @param_errors } # get here if there was no redirection -- that is, just one of # the following is true for this run of the script: # -- user came directly to the login page (no params were set), or # -- user hit the "login" submit button, but login fields were invali +d, or # -- user hit the "new user" submit button, but params were incomplet +e or # username was already in use print header(...); print start_html(...); if ( @param_errors ) { # show error message(s) } # print the form...
Now, when you redirect to some other cgi script that you have written, you can include the parameters in the url that the are known from the login process and that will be needed by the other script.

BTW, I think you have the wrong sort of logic for confirming whether the login parameters are okay. You should query the database like this:

my $select = $dbh->prepare("select email,password from users where u +sername=?"); $select->execute( $username ); my @row = $select->fetchrow_array; if ( @row != 2 or $email ne $row[0] or $password ne $dbpassword ) { push @error_mesgs, "bad login..."; } else { #login was okay, so redirect... }

In reply to Re^7: Redirecting values from 1 script to another by graff
in thread Redirecting values from 1 script to another by Nik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.