1 2 3 4 5 6 7 8 9 10 11
use strict; use warnings; use CGI; my $cgi = CGI->new(); my $next_url = 'intro.cgi'; print $cgi->header(-location => "$next_url?BLAAAAH" ); exit;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
use strict; use warnings; use CGI; my $cgi = CGI->new(); print $cgi->header(); print <<HTML; <html> <head> <title>TEST für Umleitung</title> </head> <body> <p>Gehrt doch mit Umleitung!</p> </body> </html> HTML exit;
2013-03-27T14:24:16 GwenDragonSchau bitte mal in die error.log deines Webservers, warum was nicht klappt.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
#!"C:\xampp\perl\bin\perl.exe" use strict; use IO::Handle; use DBI; use CGI; use CGI::Session; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); my $dbhost = "localhost"; my $database = "sensor"; my $dbuser = "root"; my $dbpass = ""; my $dsn = "DBI:mysql:database=$database; host=$dbhost"; my $dbh = DBI->connect($dsn, $dbuser, $dbpass); my $cgi = new CGI; my $select; print "Content-type: text/html\n\n"; print "<html><head><meta http-equiv='content-type' content='text/html; charset=utf-8' /><link rel='stylesheet' media='screen,projection' type='text/css' href='/css/main.css' /><link rel='stylesheet' media='screen,projection' type='text/css' href='/css/scheme.css' />"; print "</head>"; print "<body><form action='/cgi-bin/login.cgi' method='post'><div id='main'>"; print "<div id='footer'> <h1 id='logo'><a>sensor.<span>ct</span></a></h1> <hr class='noscreen' /> </div> "; print "<div id='navlogin'><ul class='box'><br><li><p><font face='Arial' size='6'><b>Login</b></font></p> <br><blockquote>Benutzer-ID: <br><input type='text' size='30' name='user'></li></ul><br><ul class='box'><li><blockquote>Kennwort: <br><input type='password' size='30' name='pwd'></li></ul>"; print "<br><ul class='box'><li><blockquote><br><input class='button' type='submit' name='login' value='Einloggen'></li><br></ul></div> "; print "</body></html>"; my $passwort; my $user; my $i=0; my $session; my $SIDNAME = CGI::Session->name(); my $cgi = CGI->new; my $sid = $cgi->cookie($SIDNAME) || $cgi->param($SIDNAME) || undef; my $session = CGI::Session->load() or die CGI::Session->errstr(); if ( $session->is_empty ) { $session = CGI::Session->new() or die CGI::Session->errstr(); } if ( $session->is_expired() ) { print $session->header(), $cgi->start_html(), $cgi->p("Your session timed out! Refresh the webpage!"), $cgi->end_html(); exit(0); } my $cookie = $cgi->cookie( -name => $SIDNAME, -value => $sid ); $sid = $session->id; if($cgi->param('login')) { $select = $dbh->prepare("select benutzer,passwort from benutzer WHERE benutzer=? AND passwort=?;"); $select->execute($cgi->param('user'), $cgi->param('pwd')); while(($user, $passwort) = $select->fetchrow_array) { if(($user eq $cgi->param('user')) && ($passwort eq $cgi->param('pwd'))) { $session = new CGI::Session(undef, undef, undef); # Session erzeugen #print "<font face='Arial' size='3' color=#339900><b>Anmeldung erfolgreich! Sie werden weitergeleitet...</b></font>"; $i++; $session->param( 'user',$user ); $session->param( 'loggedin', 1 ); $session->param( 'lastvisit', "" . localtime() ); my $next_url = '/localhost/cgi-bin/messung.cgi'; print $cgi->header ( -location => "$next_url?$SIDNAME=$sid", -cookie => $cookie );exit; } } if(! $i) { print "<font face='Arial' size='3' color=#CC3300><b>Anmeldung fehlgeschlagen!</b></font>"; } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
#!"C:\xampp\perl\bin\perl.exe" print "<body bgcolor=#bfbfbf>"; use strict; use DBI; use CGI; use CGI::Session; my $dbhost = "localhost"; my $database = "sensor"; my $dbuser = "root"; my $dbpass = ""; my $dsn = "DBI:mysql:database=$database; host=$dbhost"; my $dbh = DBI->connect($dsn, $dbuser, $dbpass); my $Gesamtsystemquery = $dbh->prepare("select wert from malcos_x;"); my $idMessung; my $Beschreibung; my $Wert; my $cgi = CGI->new(); my $session = CGI::Session->load() or die CGI::Session->errstr; print $session; if ($session and not $session->is_empty and not $session->is_expired) { print "angemeldet!"; } else { print "nicht angemeldet"; } print '<p><b><font size=6>Messungen:</font></b></p>'; print "<table border=1>\n"; $Gesamtsystemquery->execute; while(($idMessung, $Beschreibung, $Wert) = $Gesamtsystemquery->fetchrow_array) { print " <tr>\n"; print " <td>System</td>\n"; if($idMessung eq "0") { print "<td>aus</td>\n"; } else { print "<td>ein</td>\n"; } print " <td></td>\n"; print " </tr>\n"; } $Gesamtsystemquery->finish; $dbh->disconnect; print "<br /><br />";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
#!"C:\xampp\perl\bin\perl.exe" use strict; use DBI; use CGI; use CGI::Session; my $cgi = CGI->new(); my $session = CGI::Session->load() or die CGI::Session->errstr; if (not ($session->param('loggedin') and $session->param('loggedin') == 1 ) ) { #nicht angemeldet!!!! # Weiterleiten zum Login my $next_url = '/localhost/cgi-bin/login.cgi'; print $session->header ( -location => $next_url ); exit; } # dann ist wohl eingeloggt, also Datenbank abfragen my $dbhost = "localhost"; my $database = "sensor"; my $dbuser = "root"; my $dbpass = ""; my $dsn = "DBI:mysql:database=$database; host=$dbhost"; my $dbh = DBI->connect($dsn, $dbuser, $dbpass); my $Gesamtsystemquery = $dbh->prepare("select wert from malcos_x;"); my $idMessung; my $Beschreibung; my $Wert; print $cgi->header( -type => 'text/html'); print "<body bgcolor=#bfbfbf>"; print '<p><b><font size=6>Messungen:</font></b></p>'; print "<table border=1>\n"; $Gesamtsystemquery->execute; while(($idMessung, $Beschreibung, $Wert) = $Gesamtsystemquery->fetchrow_array) { print " <tr>\n"; print " <td>System</td>\n"; if($idMessung eq "0") { print "<td>aus</td>\n"; } else { print "<td>ein</td>\n"; } print " <td></td>\n"; print " </tr>\n"; } $Gesamtsystemquery->finish; $dbh->disconnect; print "<br /><br />";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
#!"C:\xampp\perl\bin\perl.exe" use strict; use IO::Handle; use DBI; use CGI; use CGI::Session; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); my $dbhost = "localhost"; my $database = "sensor"; my $dbuser = "root"; my $dbpass = ""; my $dsn = "DBI:mysql:database=$database; host=$dbhost"; my $dbh = DBI->connect($dsn, $dbuser, $dbpass); my $cgi = new CGI; my $select; my $passwort; my $user; my $i=0; my $session; my $SIDNAME = CGI::Session->name(); my $sid = $cgi->cookie($SIDNAME) || $cgi->param($SIDNAME) || undef; $session = CGI::Session->load() or die CGI::Session->errstr(); if ( $session->is_empty ) { $session = CGI::Session->new() or die CGI::Session->errstr(); } if ( $session->is_expired() ) { print $session->header(), $cgi->start_html(), $cgi->p("Your session timed out! Refresh the webpage!"), $cgi->end_html(); exit(0); } my $cookie = $cgi->cookie( -name => $SIDNAME, -value => $sid ); $sid = $session->id; my $errormessage; if($cgi->param('login')) { $select = $dbh->prepare("select benutzer,passwort from benutzer WHERE benutzer=? AND passwort=?;"); $select->execute($cgi->param('user'), $cgi->param('pwd')); while(($user, $passwort) = $select->fetchrow_array) { if(($user eq $cgi->param('user')) && ($passwort eq $cgi->param('pwd'))) { #print "<font face='Arial' size='3' color=#339900><b>Anmeldung erfolgreich! Sie werden weitergeleitet...</b></font>"; $i++; $session->param( 'user',$user ); $session->param( 'loggedin', 1 ); $session->param( 'lastvisit', "" . localtime() ); my $next_url = '/localhost/cgi-bin/messung.cgi'; print $session->header ( -location => "$next_url?$SIDNAME=$sid", -cookie => $cookie ); exit; } } if(! $i) { $errormessage = "<font face='Arial' size='3' color=#CC3300><b>Anmeldung fehlgeschlagen!</b></font>"; } } print $session->header( -type => 'text/html'); print "<html><head><meta http-equiv='content-type' content='text/html; charset=utf-8' /><link rel='stylesheet' media='screen,projection' type='text/css' href='/css/main.css' /><link rel='stylesheet' media='screen,projection' type='text/css' href='/css/scheme.css' />"; print "</head>"; print "<body>"; print "<p>$errormessage</p>"; print "<form action='/cgi-bin/login.cgi' method='post'><div id='main'>"; print "<div id='footer'> <h1 id='logo'><a>sensor.<span>ct</span></a></h1> <hr class='noscreen' /> </div> "; print "<div id='navlogin'><ul class='box'><br><li><p><font face='Arial' size='6'><b>Login</b></font></p> <br><blockquote>Benutzer-ID: <br><input type='text' size='30' name='user'></li></ul><br><ul class='box'><li><blockquote>Kennwort: <br><input type='password' size='30' name='pwd'></li></ul>"; print "<br><ul class='box'><li><blockquote><br><input class='button' type='submit' name='login' value='Einloggen'></li><br></ul></div> "; print "</body></html>";
2013-03-27T18:51:04 anamollo4musicAlso sowohl login.cgi als auch intro.cgi klappt jetzt?(...)
EDIT: Hat sich erledigt. Habe nämlich testweise statt auf eine CGI auf eine "index.html" verwiesen...