For the codes, they are okay. The problem is that I didn't chmod the ~/public_html/cgi-bin 's privilige before I want to run the cgi script on an explorer. The vision is that when you excute it on the server, you may be the root user, but when you run the script through an explorer, you are a non-root user, so maybe you don't have the right to change anything inside the cgi-bin directory. And for my code, I want to use the function: fopen(), that's a kind of function depending on the user's privlige. So after doing "chmod a+w cgi-bin" action, I can run the script through an explorer. But the most disadvantage is that this kind of setting has much potential and monster danger. For that some hacker may damage your system by some dangerous cgi-script because of the high privilge you gave them. Have fun....