Thread: Password for Website

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    6

    Password for Website

    Hey everyone:

    Well today I started playing with html but I can't figure out how to require like a password or registration code to go into certain pages.

    I need to be able to require somesort of login requirement to protect the page since I'm posting programs I wrote in C for a college class. I also want to be able to collect a list of email addresses corresponding to different codes so my old teacher can know whos looking at them so I'm not just cheating for other people and dont get into any trouble.

    Any suggestions? I really don't know how to go about it. Ive tried just about every CGI posting around and its just outside of my knowledge.

    Any help would be greatly apprecated. Thanks!

    My horrible failures thus far...
    Code:
          <h1>Programs</h1>
             <h2>Password/Registration Required</h2>
                <blockquote>
                <h3>Registration Number</h3>
                    <form method="post" action="clearing.cgi">                
                       <p>Enter Registration Code Here: <input type="text" name="regisnum" size="10" value="Regis$
                       <input type="submit" name="Regis" action="clearing.cgi" value="Submit">
                    </form>
    Code:
    #include <stdio.h>
    
    void passed (void);
    
    int main(int argc, char *argv[])
    {
       char *regisnum;
       char *password;
       char Buffer[10]; 
       int InputLength = atoi( getenv("INPUT_LENGTH") ); 
    
       fread( Buffer, InputLength, 1, stdin ); 
       
       if((regisnum = argv[1]) == "100")
       {
          printf("Admitted");
          printf("\n<HTML><BODY><A HREF="regis/regis.html">Redirecting</A>");
          printf("</BODY></HTML>\n");
          passed();
       }
       else if ((password = argv[1]) == "100")
       {
          printf("Admitted");
          passed();
       }
       else
          printf("Password or Registration Number is not valid!");
    
    
       return 0;
    }
    
    void passed(void)
    {
       printf("Content-type: text/html\n\n"); 
       printf("<HTML><HEAD><TITLE>Processing</TITLE></HEAD><BODY>\n");
    //   printf("<h1><A HREF="regis/regis.html" target="_self">Redirecting</A></h1>\n\n"); 
       printf( "</BODY></HTML>\n"); 
    }

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    250
    Can't you just alter the access restrictions on the files stored on your server directly (chmod)?

    BTW #1 Why are you asking this in a C programming forum?
    BTW #2 I doubt that collecting people's email addresses AND giving them to a third parties without their explicit consent is legal. In any case it's not 'proper'. So be sure to include this in the 'terms of agreement' when you have people signing up for your page.
    Last edited by MWAAAHAAA; 05-27-2007 at 03:32 AM.

  3. #3
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    #1 because it's C ...

  4. #4
    Registered User
    Join Date
    Apr 2006
    Posts
    6
    Quote Originally Posted by MWAAAHAAA View Post
    BTW #2 I doubt that collecting people's email addresses AND giving them to a third parties without their explicit consent is legal. In any case it's not 'proper'. So be sure to include this in the 'terms of agreement' when you have people signing up for your page.
    Thats the point...they will know their email is being given to their professor...to encourage them not to cheat. I just cant figure out how to get an email address and associate a code with it that will allow them to login. I've tried html post method action stuff...but I just cant find/figure out what the output parameters are so I can use them in a C program.

  5. #5
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    You need to do a bit of research on CGI programming in C.

    I would, since you don't want to implement a DB:
    * Register the user by creating a new file (with the name of their email)
    * When they login it checks their password in the 'email' file... And if it doesn't exist, well they haven't registered.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading a password from a file.
    By medeshago in forum C Programming
    Replies: 15
    Last Post: 12-21-2008, 07:20 AM
  2. [Q]Hide Password
    By Yuri in forum C++ Programming
    Replies: 14
    Last Post: 03-02-2006, 03:42 AM
  3. written command line password generator
    By lepricaun in forum C Programming
    Replies: 15
    Last Post: 08-17-2004, 08:42 PM
  4. Password prompt in unix w/o \b
    By rafe in forum C++ Programming
    Replies: 1
    Last Post: 10-09-2002, 08:54 AM
  5. password
    By hammers6 in forum C Programming
    Replies: 1
    Last Post: 10-10-2001, 12:14 AM