PHP Login Page with file upload functionality

Discussion in 'PHP' started by Floridasites, Nov 26, 2007.

  1. #1
    Hello All.. I need some general help..

    I have a general html / flash site that I created. I would like to add a link on the bottom of the site where only our member users can login to..

    Once they click on the link, they will be directed to a login page where they need to put in username and password. Then inside this page, I would like a file sharing place where users can upload files such as document, pdf files, photos, etc.

    Can you please give me some help on how to do the login page and then also any scripts or how to tutorials to do the file sharing interface. Im just getting acquainted with PHP so all helps is appreciated.

    Thanks All. :)
     
    Floridasites, Nov 26, 2007 IP
  2. lounar

    lounar Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello,
    well u will need to make two tables, a user and a members tables so u can save there the registration username and password so they can login after registering.


    <?php
    
    
    
    if (isset($_POST['username'])){
    
    	$username = $_POST['username'];
    
    	$password = $_POST['password'];
    
    	
    
    	include ('inc/db_open.php');
    
    	 
    
    	$query = "select * from user, members where user.username='$username' and user.pass=PASSWORD('$password') and user.memID=members.memID";
    
    	
    
    	$result = mysql_query($query) or die ('Query failed'.mysql_error());
    
    	
    
    	if (mysql_num_rows($result) == 1){
    
    		$row = mysql_fetch_array($result);
    
    		$_SESSION['username'] = $username;
    
    		$_SESSION['memID'] = $row['memID'];
    
    		$_SESSION['login'] = true;
    	
    
    			if($row['status'] == 1){
    
    			$_SESSION['status'] = 1;
    
    		}
    		
    		elseif($row['status'] == 2){
    
    			$_SESSION['status'] = 2;
    
    		}
    		
    		elseif($row['status'] == 3){
    
    			$_SESSION['status'] = 3;
    			}
    			
    		elseif($row['status'] == 4){
    
    			$_SESSION['status'] = 4;
    			}
    		
    		
    		else{
    
    			$_SESSION['status'] = false;
    
    		}
    
    		?>
    
    		<script type="text/javascript">
    
    		//Get the current page name
    
    		var sPath = window.location.pathname;
    
    		var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    
    		
    
    		//transfer user to the current page
    
    		window.location=sPage;
    
    		</script>		
    
    		<?php	
    
    	}
    
    	else{
    
    			?>
    
    			<script type="text/javascript">
    
    			window.location="inc/incorrectlogin.php";
    
    			</script>		
    
    			<?php
    
    	}	
    
    }
    
    ?>
    			<script type="text/JavaScript">
    <!--
    function MM_controlSound(x, _sndObj, sndFile) { //v3.0
      var i, method = "", sndObj = eval(_sndObj);
      if (sndObj != null) {
        if (navigator.appName == 'Netscape') method = "play";
        else {
          if (window.MM_WMP == null) {
            window.MM_WMP = false;
            for(i in sndObj) if (i == "ActiveMovie") {
              window.MM_WMP = true; break;
          } }
          if (window.MM_WMP) method = "play";
          else if (sndObj.FileName) method = "run";
      } }
      if (method) eval(_sndObj+"."+method+"()");
      else window.location = sndFile;
    }
    //-->
                </script>
    			
                <center>
                  <table cellpadding="0" cellspacing="0" border="0" width="220" bgcolor="#509BB8">
                    <tr>
                      <td height="10"></td>
                    </tr>
                    <tr>
                      <td align="center"><a class="mainMenu" >Login </a></td>
                    </tr>
                    <form name="login" method="post" action="<? echo $_SERVER['PHP_SELF']; ?>">
                      <tr>
                        <td height="10" align="center"> Username:<br />
                            <input type="text" name="username" />
                          Password:<br />
                          <input type="password" name="password" />
                        </td>
                      </tr>
                      <tr>
                        <td align="center"><input type="submit" value="Login" />
                        </td>
                      </tr>
                    </form>
                    <tr>
                      <td height="10"></td>
                    </tr>
                    <tr>
                      <td height="10"></td>
                    </tr>
                    <tr>
                      <td align="center"><a href="ll.php" class="mainMenu" onmouseover="MM_controlSound('play','document.CS1194471367328','sound.wav')">Our Hotel</a></td>
                    </tr>
                    <tr>
                      <td height="10"></td>
                    </tr>
                    
    PHP:
    this is the code that i use for login so take it and make it to work to your db!
     
    lounar, Nov 26, 2007 IP
  3. Floridasites

    Floridasites Peon

    Messages:
    141
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thank you, I will give this code a try..

    Do you know a script for the uploading documents / files among each member.
    I am hoping kinda like a window explorer interface for ease of use... (doesn't have to be like window explorer but it would just be nice)..

    thanks.
     
    Floridasites, Nov 27, 2007 IP