Jump to content

IrOnMaSk

Members
  • Posts

    149
  • Joined

  • Last visited

    Never

Posts posted by IrOnMaSk

  1. Hi guys,

    I'm using this upload/extract zip script. I wonder if I can modify the script to link the file after it is unzip. Now it just unzip and show the content, I want to give the link to that content. Please let me know if this even possible with the code below.

    <form enctype="multipart/form-data" action="index.php" method="POST">
    Upload a Zip Archive (*.zip): <input name="zip" type="file" /><input type="submit" value="Upload" />
    </form>
    <?php
    /*
    UnZip on Server - using PHP
    by 3scriptz.com  
    */  
    //check if file is uploaded
    if(isset($_FILES['zip'])){
    require_once('pclzip.lib.php'); //include class
    
    $upload_dir = 'uploads'; //your upload directory NOTE: CHMODD 0777
    $filename = $_FILES['zip']['name']; //the filename
    
    //move file
    if(move_uploaded_file($_FILES['zip']['tmp_name'], $upload_dir.'/'.$filename))
        echo "Uploaded ". $filename . " - ". $_FILES['zip']['size'] . " bytes<br />";
    else
    	die("<font color='red'>Error : Unable to upload file</font><br />");
    
    $zip_dir = basename($filename, ".zip"); //get filename without extension fpr directory creation
    
    //create directory in $upload_dir and chmodd directory
    if(!@mkdir($upload_dir.'/'.$zip_dir, 0777))
    	die("<font color='red'>Error : Unable to create directory</font><br />");
    
    $archive = new PclZip($upload_dir.'/'.$filename);
    
    if ($archive->extract(PCLZIP_OPT_PATH, $upload_dir.'/'.$zip_dir) == 0)
    	die("<font color='red'>Error : Unable to unzip archive</font>");
    
    //show what was just extracted
    $list = $archive->listContent();
    echo "<br /><b>Files in Archive</b><br />";
    for ($i=0; $i<sizeof($list); $i++) {
    
    	if(!$list[$i]['folder'])
    		$bytes = " - ".$list[$i]['size']." bytes";
    	else
    		$bytes = "";
    
    	echo "".$list[$i]['filename']."$bytes<br />";
    }
    
    unlink($upload_dir.'/'.$filename); //delete uploaded file
    }
    ?>
    

    Thanks

  2. Thanks for your reply jj, it makes sense. I'm not sure though to how I implement that into the script. So here's how I check to see if username/password match when user login.

    <?php 
    
    // Connects to your Database 
    
    mysql_connect("localhost", "Sopoan", "Javascrip1") or die(mysql_error()); 
    
    mysql_select_db("member") or die(mysql_error()); 
    
    
    //Checks if there is a login cookie
    
    if(isset($_COOKIE['ID_my_site']))
    
    
    //if there is, it logs you in and directes you to the members page
    
    { 
    	$username = $_COOKIE['ID_my_site']; 
    
    	$pass = $_COOKIE['Key_my_site'];
    
    	 	$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
    
    	while($info = mysql_fetch_array( $check )) 	
    
    		{
    
    		if ($pass != $info['password']) 
    
    			{
    
    			 			}
    
    		else
    
    			{
    
    			header("Location: members.php");
    
    
    
    			}
    
    		}
    
    }
    
    
    //if the login form is submitted 
    
    if (isset($_POST['submit'])) { // if form has been submitted
    
    
    
    // makes sure they filled it in
    
    	if(!$_POST['username'] | !$_POST['pass']) {
    
    		die('You did not fill in a required field.');
    
    	}
    
    	// checks it against the database
    
    
    
    	if (!get_magic_quotes_gpc()) {
    
    		$_POST['email'] = addslashes($_POST['email']);
    
    	}
    
    	$check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error());
    
    //Gives error if user dosen't exist
    
    $check2 = mysql_num_rows($check);
    
    if ($check2 == 0) {
    
    		die('That user does not exist in our database. <a href=registration.php>Click Here to Register</a>');
    
    while($info = mysql_fetch_array( $check )) 	
    
    {
    
    $_POST['pass'] = stripslashes($_POST['pass']);
    
    	$info['password'] = stripslashes($info['password']);
    
    	$_POST['pass'] = md5($_POST['pass']);
    
    //gives error if the password is wrong
    
    	if ($_POST['pass'] != $info['password']) {
    
    		die('Incorrect password, please try again.');
    
    	}
    
    	else 
    
    { 
    
    // if login is ok then we add a cookie 
    
    	 $_POST['username'] = stripslashes($_POST['username']); 
    
    	 $hour = time() + 3600; 
    
    setcookie(ID_my_site, $_POST['username'], $hour); 
    
    setcookie(Key_my_site, $_POST['pass'], $hour);	 
    
    //then redirect them to the members area 
    
    header("Location: members.php"); 
    
    } 
    
    } 
    
    } 
    
    else 
    
    {	 
    
    // if they are not logged in 
    
    ?> 
    
    <form action="login.php" method="post"> 
    
    <table border="0"> 
    
    <tr><td colspan=2><h1>Login</h1></td></tr> 
    
    <tr><td>Username:</td><td> 
    
    <input type="text" name="username" maxlength="40"> 
    
    </td></tr> 
    
    <tr><td>Password:</td><td> 
    
    <input type="password" name="pass" maxlength="50"> 
    
    </td></tr> 
    
    <tr><td colspan="2" align="right"> 
    
    <input type="submit" name="submit" value="Login"> 
    
    </td></tr> 
    
    </table> 
    
    </form> 
    
    <?php 
    
    } 
    ?> 
    

    Thanks

  3. if you want to check if the send button was click

    use

      if(isset($_POST['subment']))
      {
         if( condition)
         {
            //if $car_class is false execute code here
          }
      }
    

    the isset will check if the button is pressed assument the button is named 'submit'

     

    @KDM: FYI- this could be condensed into one statement if you wanted; like:

    if (isset($_POST['submit']) && $car_class == FALSE) {
    // code to execute
    }

    no, don't do that!!!

    the,

    reason,

    is

    i'm kidding :D

  4. it's more a question of css but i'm sure people can answer it...

    try change these two lines

    #lightbox img{ width: 505px; height: auto;}

    if not working trying this

    #outerImageContainer{ position: relative; background-color: #fff; width: 250px; height: 250px; margin: 0 auto; }

  5. in this case if the OP doesnt even understand how to write a simple if statement, i beleive that the manual is the best place for him/her to look and understand PHP..i agree with what Maq posted, will lead to more enlightment here

    i usually have a hard time understanding the manual actually because they don't explain much just show you with examples...

    i go there for syntax not for understanding :) but not all people are a like 8) we all are unique and special like everyone else lol

  6. The error message is self explanatory. Your products table does not have a column named category. Check your spelling of the actual column name.

    that's too abvious that's y i didn't even mention!!! if that's the case, i'll go hurt myself :'(

  7. the whole point of the form is that users fill them in and go to the next page...

    but if you want to proceed to proceed anyway (kinda pointless) you can do away the funtion died()

    function died($error) {        
    // your error code can go here        
    echo "We are very sorry, but there were error(s) found with the form you submitted. ";        
    echo "These errors appear below.<br /><br />";        
    echo $error."<br /><br />";        
    echo "Please go back and fix these errors.<br /><br />";        
    die();    
    }
    

    and the validation

    if(!isset($_POST['first_name']) ||        
    !isset($_POST['last_name']) ||        
    !isset($_POST['email']) ||        
    !isset($_POST['telephone']) ||        
    !isset($_POST['comments'])) {        
    died('We are sorry, but there appears to be a problem with the form you submitted.');          
    }
    

  8. i would put form in same file with the php file...

    and start out by hiding the form...

    so do the if statement like what you do and reveal the form when the condition is not met...

    let me know if need help wit the code part

  9. to validate that email address is real, use this simple function

    function myCheckDNSRR($hostName, $recType = '') <BR>   
    { <BR>   
      if(!empty($hostName)) { <BR>   
        if( $recType == '' ) $recType = "MX"; <BR>   
        exec("nslookup -type=$recType $hostName", $result); <BR>   
        // check each line to find the one that starts with the host <BR>   
        // name. If it exists then the function succeeded. <BR>   
        foreach ($result as $line) { <BR>   
          if(eregi("^$hostName",$line)) { <BR>   
            return true; <BR>   
          } <BR>   
        } <BR>   
        // otherwise there was no mail handler for the domain <BR>   
        return false; <BR>   
      } <BR>   
      return false; <BR>   
    }
    

    Don't get it?

    go here http://www.sitepoint.com/users-email-address-php/  ;D

  10. I tried moving $details in front of $category and got the same result, any other ideas??

    it doesn't matter what order of data you grabing from the form as long as you match them up correctly.

    and try to swap the position of the category like u did in the insert statement but in the database...

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.