It shows that you are unregistered. Please register with us by clicking Here
![]() |
|
![]() |
![]() | Register - FAQ - Today's Posts - New Posts - Support - Search | ![]() |
|
|
#1 (permalink) |
|
Member
Join Date: Jul 2006
Age: 25
Posts: 53
|
#!/usr/bin/perl -wT
use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use DBI; use strict; print header(); print start_html("Welcome"); my $dbh = DBI->connect( "dbi:mysql # declare some variables my ($cookie_id, $username); if (cookie('userID')) { # found a cookie! my $sth = $dbh->prepare("select * from user_cookies where cookie_id=?") or &dbdie; $sth->execute(cookie('userID')) or &dbdie; if (my $rec = $sth->fetchrow_hashref) { $cookie_id = cookie('userID'); $username = $rec->{username}; } } if ($cookie_id) { print h2("Welcome back, $username!"); } else { print h2("Welcome!"); print qq( <form action="cookieform.cgi" method="POST"> This appears to be your first visit. Please enter your name: <input type="text" name="username"> <input type="submit" value="Enter"> </form> <br> ); } print end_html; $dbh->disconnect; sub dienice { my($msg) = @_; print "<h2>Error</h2>\n"; print $msg; exit; } sub dbdie { my($package, $filename, $line) = caller; my($errmsg) = "Database error: $DBI::errstr<br> called from $package $filename line $line"; &dienice($errmsg); } |
|
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to send cookies to the client | Tom Tom | .NET | 1 | 06-14-2007 12:02 AM |
| Tracking 55.1 Million Blogs | Eric | All Other SE's & Directories | 18 | 10-17-2006 09:07 AM |
| Order Tracking? | Jewls | Website Design | 7 | 08-11-2006 03:24 AM |
| Not Tracking Anymore | LouisianaNurse | All Things General | 5 | 07-10-2006 07:59 PM |
| WHERE do I put the tracking code for my blog??? | Nail | All Things General | 0 | 05-17-2006 08:23 AM |