Jump to content

IrOnMaSk

Members
  • Posts

    149
  • Joined

  • Last visited

    Never

Everything 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. Hey guys, How do I check to see if the user has been login on the page that they are on? I have a login and I want users to login before then can go to other pages. thanks guys,
  4. so the images is always show up by their default sizes? check the deminsion of the image once loaded against the actual image and see if they are the same
  5. demonstration: "I ain't gotcha"
  6. @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
  7. in this case if it is named.. "subment" ... yup, thnx AK47 i can't type today :'(
  8. it's more a question of css but i'm sure people can answer it... try change these two lines if not working trying this
  9. 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'
  10. totally agree. i feel like the manual is for the elites lol, maybe just me and there's a fine line between being uniqu/speical and nerd/geek
  11. 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 we all are unique and special like everyone else lol
  12. is that line 421? here's the structure of if statement if( condition ) { //execute code if condition is true } you didn't close the codition ")" so close the condition after the ==False
  13. that's too abvious that's y i didn't even mention!!! if that's the case, i'll go hurt myself :'(
  14. 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.'); }
  15. 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
  16. 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/
  17. just typo mistake <?php $result = mysql_query("SELECT * FROM opi order by row desc");//error message can go here after ;
  18. 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...
  19. all the forms on same page? so what's the purpose of refreshing the page? isn't it to test the form? well, you can comment out the post in the form
  20. possible it is ok, try to swap the position of category column in the database table... that seems to solve the problem -- assuming no syntax error ... it might solve ur problem
  21. i don't think you can insert the date like that: try this:http://www.ntchosting.com/mysql/insert-date.html
  22. maybe this?http://php.net/manual/en/language.variables.scope.php probly not
  23. define it outside and above the function... and you can only call it from within the page anywhere but not from different page...
×
×
  • 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.