Here are a few pointers. I hope they help to get things started. First off, read How to RTFM. Then:
let's say i'm working on a script, and there are some admin subroutines, what do i have to do to get apache to request user authentication only on these subs, and how do i do to put my userid and pass in the pass file(how do i use htpasswd.exe)
1. Put the admin scripts in their own directory - a subdirectory of the cgi-bin will be easiest.
2. Within that directory, type htpasswd -c .htpasswd admin to create a password file and put the user 'admin' in it. You'll be prompted twice to enter the password. See the apache docs for more information about what's going on here.
3. create a file called .htaccess in that directory. In there you'll put the instructions that tell apache that access to this directory requires authentication of a user in the .htpasswd file you've just created. That's way off topic for this site, but see this page for instructions and this one for examples.
4. If you want your scripts to read or update the password file you've created, the easiest way is to use the Apache::Htpasswd module. It's on cpan.
let's say i'm working on a script, and there are some admin I wanna put binary data in my mySql db. so i used CGI for first time to get the uploaded data, and i created a colum mediumblob so, mysql statemet is INSERT INTO img VALUES (NULL, $img) would this work??
Two tasks here: capture the binary data, and feed it into the database. That's not beginner perl, but it's not all that hard. CGI.pm will provide the data capture without you having to do much work at all, but you will have to rtfm on that one. There are also nodes here that will help, or at least motivate. Your immediate question is addressed by creating a file upload field, but you'll need to adapt the filehandle code to write the data into a query rather than a file.
For efficient display of the uploaded image, you'll also need to store information about its dimensions (and preferably some alt text). You can ask the user for that, but it's a pain: you're better off using the very excellent Image::Size module.
Your query as it stands will work if it matches the order of the columns in your image table, and the first column doesn't mind being null. It's probably better to make the first column an auto-incrementing id field and just use INSERT INTO img (data) VALUES ($img). Don't forget to call $dbh->quote() on the data beforehand. Again, there's no way you can avoid reading the mysql and dbi docs, so you might as well start now.
Now, i'm thinking about doing a live audio thing, like. i want people to hear what's goin on in my room whenever they want, i have no clue how to do that.
I suggest you wait until a clue arrives and do it then. This might help.
i'm just turned a computer into a web server, where can i get sendmail or something like that?? i need to recieve mail too. what should i do?
alright dudes, i guess that's all, thanks for the help, later. oh yeah, by the way. help me and then you can bitch about this node, i tried my best to make it good.
Most of the links here came from five minutes on google. There are a lot of good howtos and guides out there for people in exactly your situation. Consult them first, ask the questions that come up when you try and do what they say, and you'll get a lot more help and a lot less bitching out of places like this.
And please don't be dismayed, by the steepness or the bitching. It's not brain surgery, it just takes a little while to learn the jargon and use it to find the resources that'll make all this easy.
In reply to Re: Lots of simple question about CGI
by thpfft
in thread Lot's of simple question about CGI
by pokemonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |