Re: looking for a host
Hurricane Electric http://www.he.net $9.95 /mo basic They provide more functions than almost anyone. On Wednesday 05 February 2003 04:14 pm, Shahar Evron wrote: > hi all.. > i'm doing all sorts of tests with CGI related perl, and i need a good > host that supports perl and SSI to run my scripts on. > I'm working with one of those free web site hosting companies that put > ads on my pages, and i have problems with stuff like viewing logs, > installing moudules and stuff. > can anyone recommend a good (and free) solution? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help with Cookies
> All am I am trying to do now is have a user enter his/her > name in a form and have that saved to a cookie, so when they > return, they will get something like " Your juser, please > proceed" . I took the example here: > http://stein.cshl.org/WWW/CGI/examples/cookie.cgi > > Below is the code I am working with. But when I return to > the page I just get the form again. What am i missing. Sorry > if this is obvious, but i am not getting it and I have read > the tutorial and the RFC on http state (thanks John ). I revised the code to get rid of the obvious mistakes. I can see that the cookie is made, but how can get it to print the user after it reads that there is indeed a a cookie. here is what i have now: --- use CGI qw(:standard); # get cookie if it is there %all = cookie('user'); # Recover the new users from the form parameter 'new_user' $new = param('new_user'); # Add the user submitted in the form as the new cookie $cookie = cookie(-name=>'user', -value=>$new, -expires=>'+1h'); # Print the header, incorporating the cookie and the expiration date... print header(-cookie=>$cookie); # Now we're ready to create our HTML page. print start_html('Test cookie'); if (%all) { # shouldn't it print if there is a cookie found?? foreach $key ( keys %all) { print "$all{$key}"; } } else { print " NO USERS SAVED " }; print qq( User Name: ); print end_html; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Data Validation Issues
Greets Folks, I am developing a registration area for a members site that will interface with a MySQL DB users table, and I ran into a problem or two. Note that I am using DBI as my DB Driver. First, the simple stuff. I need a way to (at run-time) confirm all the fields have been filled in, and, if one has been overlooked, then to notify the user where they missed. Second, suppose they try a username that has already been taken. I need a way to kick back an error message to them. I tried setting the username field in the usrs table to UNIQUE, so that might help if someone tried to insert something already taken... I was thinking that if MySQL kicks back an error message, then DBI might be able to recongize it in such a way that I could use the return value... I dont know if that is completely feasible though... there may be other, better ways anyway... so I'm all ears... Any help much appreciated. Thanks, Will __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Data Validation Issues
Will wrote: > Greets Folks, > > I am developing a registration area for a members site > that will interface with a MySQL DB users table, and I > ran into a problem or two. Note that I am using DBI as my DB Driver. > > ... > > Second, suppose they try a username that has already > been taken. I need a way to kick back an error > message > to them. I tried setting the username field in the > usrs table to UNIQUE, so that might help if someone > tried to insert something already taken... I was > thinking that if MySQL kicks back an error message, > then DBI might be able to recongize it in such a way > that I could use the return value... I dont know if > that is completely feasible though... there may be > other, better ways anyway... so I'm all ears... $DBI::err will have the database engine error code from the last call. You'll have to figure out which value MySQL uses for unique constraint violation. You can then test for that in your script. $dbh->{RaiseError} = 0; # don't die on error $dbh->do('insert into user (name) values ?', undef, $username); if ($DBI::err == 999) { # replace 999 with the correct error code! print "Duplicate user\n"; elsif ($DBI::err) { print "Unexpected error: $DBI::errstr\n"; } See perldoc DBI under the heading "METHODS COMMON TO ALL HANDLES" -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Data Validation Issues
on vr, 07 feb 2003 18:54:25 GMT, Will wrote: > Second, suppose they try a username that has already > been taken. I need a way to kick back an error > message > to them. I tried setting the username field in the > usrs table to UNIQUE, so that might help if someone > tried to insert something already taken... I was > thinking that if MySQL kicks back an error message, > then DBI might be able to recongize it in such a way > that I could use the return value... I dont know if > that is completely feasible though... there may be > other, better ways anyway... so I'm all ears... I would not rely on an error-message from the database, but check for the existence of a username myself, e.g. like such (untested): my $username = param('username'); # from webform my $dbusername = $dbh->selectrow_array(qq{ SELECT username FROM usertable WHERE username = ? }, undef, $username); if ($dbusername) { # username already in the database } else { # username not yet in the database } -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]