Afsaneh Mardani
Q1) What does the following statement do in a Linux environment?
g++ -o   dbase.cgi   dbase.cpp
chmod 755 dbase.cgi –
A1)a- Compiles the dbase.cpp  and place the executable object under the file called: dbase.cgi 
b- change mode to executable (run-able)by the system- This command sets the file permissions so that you can read, write and execute the file and all other users(including the web server) can read and execute it.

Q2) Name the two directories that you must create in a Linux environment to run a web database.
A2) cgi-bin and public_html

Q3) How would you make your username, the directories, and your html file read and write accessible on public.
A3) To make a file world-writable :chmod 666 myfile.dat and to set a directory world-writable you’d do : chmod 777 directoryname

Q4) What does the following URL do?
http://pcfox.net/~ebrahimi/
A4) if ebrahimi  has an ccount on pcfox.net(a server),Ebrahimi URL is the above mentioned address.

Q5)  What does this do?
http://pcfox.net/~ebrahimi/dbase.htm/
A5) it goes to server pcfox.net and username ebrahimi URL .It opens up the html page called dbase.

Q6) How does a CGI program handle the following string?
f=John&f=Doe
A6) The strategy is that every data has a field name(f) followed by =, its value, and a separator (&) before the next field’s name. The program has to skip two characters to get to the value of the first input and, after that, three characters must be skipped between values. Here the program chops of the “f=” and “&f=” from “f=John&f=Doe “ and the final display is John Doe  

Q7) Is this statement correct for a CGI program?
cout<<"Content type:text/html\n";
A7) the correrct form should be as : cout<<"Content-type: text/html\n\n";  the codes is missing a “-“ and one more“\n”.

Q8) What does the following statement do?
for(i=2;str[i]!='&';i++){
     fname[n]=str[i];
     n++;}
fname[n++]=0;
A8) This code in CGI expresses that every data has a field(f) name followed by =, its value, and a separator (&) before the next field’s name. The program has to skip two characters(“f=”) to get to the value of the first input (and stops as it gets to “&”)and, after that, three characters(“&f=”) must be skipped between values. 
Generally speaking this CGI program is to take in two strings and display them .The result of the code will be Just the first name(whatever it is).

Q9) Create a HTML file which contains a database menu includes insert.html and search.html 
A9) HTML for the database menu






Employee Database


Please select from the following choices:

Q10) What does the following code do? ifstream record2("employee.txt", ios::in); cout<<"TABLE BORDER=5">First Name"; while(record2>>emp[i].fname){ cout<<""<"; } cout<<"

"; A10) this is a part of CGI program that takes the data from the text file (employee.txt)in a table with border”5” which includes First name and and displays it in web page ( the Record(s) of First name(s) from the text file under the “First name” column in the table. Then 2 line space.