Browsing articles in "MySQL"

A Simple PHP Multi Uploader with rand() and time()

May 17, 2009   //   by nuhil   //   MySQL, PHP, Tips for the New  //  1 Comment

I think this would be the simplest file multi uploader to an specific location. It uses copy() for the upload method and add a random number based on time to avoid replacement of the files including same file name.

This is the approach:

The form for uploading:

  1. <table border="0" cellspacing="1" cellpadding="0" width="500" align="center" bgcolor="#cccccc">
  2. <tbody>
  3. <tr>
  4. <form id="form1" action="multiple_upload_ac.php" enctype="multipart/form-data" method="post">
  5. <td>
  6. <table border="0" cellspacing="1" cellpadding="3" width="100%" bgcolor="#ffffff">
  7. <tbody>
  8. <tr>
  9. <td><strong>multiple Files Upload </strong></td>
  10. </tr>
  11. <tr>
  12. <td>Select file
  13. <input id="ufile[]" name="ufile[]" size="50" type="file" /></td>
  14. </tr>
  15. <tr>
  16. <td>Select file
  17. <input id="ufile[]" name="ufile[]" size="50" type="file" /></td>
  18. </tr>
  19. <tr>
  20. <td>Select file
  21. <input id="ufile[]" name="ufile[]" size="50" type="file" /></td>
  22. </tr>
  23. <tr>
  24. <td align="center">
  25. <input name="Submit" type="submit" value="Upload" /></td>
  26. </tr>
  27. </tbody></table>
  28. </td>
  29. </form></tr>
  30. </tbody></table>

multi

The processor file:

“);
  1. $path1=$path1a.time().$num1.'_'.basename($_FILES['ufile']['name'][0]);
  2.  
  3. //add a random name with the base name
  4. $path2=$path2a.time().$num2.'_'.basename($_FILES['ufile']['name'][1]);
  5. $path3=$path3a.time().$num3.'_'.basename($_FILES['ufile']['name'][2]);
  6.  
  7. //copy file to where you want to store file
  8. copy($_FILES['ufile']['tmp_name'][0], $path1);
  9. copy($_FILES['ufile']['tmp_name'][1], $path2);
  10. copy($_FILES['ufile']['tmp_name'][2], $path3);
  11.  
  12. //$_FILES['ufile']['name'] = file name
  13. //$_FILES['ufile']['size'] = file size
  14. //$_FILES['ufile']['type'] = type of file
  15. echo "File Name :".$_FILES['ufile']['name'][0]."
  16. ";
  17. echo "File Size :".$_FILES['ufile']['size'][0]."
  18. ";
  19. echo "File Type :".$_FILES['ufile']['type'][0]."
  20. ";
  21. echo "<img src="\" alt="" width="150" height="150" />";
  22. echo "
  23. ";
  24.  
  25. echo "File Name :".$_FILES['ufile']['name'][1]."
  26. ";
  27. echo "File Size :".$_FILES['ufile']['size'][1]."
  28. ";
  29. echo "File Type :".$_FILES['ufile']['type'][1]."
  30. ";
  31. echo "<img src="\" alt="" width="150" height="150" />";
  32. echo "
  33.  
  34. ";
  35.  
  36. echo "File Name :".$_FILES['ufile']['name'][2]."
  37. ";
  38. echo "File Size :".$_FILES['ufile']['size'][2]."
  39. ";
  40. echo "File Type :".$_FILES['ufile']['type'][2]."
  41. ";
  42. echo "<img src="\" alt="" width="150" height="150" />";
  43.  
  44. ///////////////////////////////////////////////////////
  45.  
  46. // Use this code to display the error or success.
  47.  
  48. $filesize1=$_FILES['ufile']['size'][0];
  49. $filesize2=$_FILES['ufile']['size'][1];
  50. $filesize3=$_FILES['ufile']['size'][2];
  51.  
  52. if($filesize1 &amp;&amp; $filesize2 &amp;&amp; $filesize3 != 0)
  53. {
  54. echo "We have recieved your files";
  55. }
  56.  
  57. else {
  58. echo "ERROR…..";
  59. }
  60.  
  61. //////////////////////////////////////////////
  62.  
  63. // What files that have a problem? (if found)
  64.  
  65. if($filesize1==0) {
  66. echo "There're something error in your first file";
  67. echo "
  68. ";
  69. }
  70.  
  71. if($filesize2==0) {
  72. echo "There're something error in your second file";
  73. echo "
  74. ";
  75. }
  76.  
  77. if($filesize3==0) {
  78. echo "There're something error in your third file";
  79. echo "
  80. ";
  81. }
  82.  
  83. ?&gt;

Download the code from left flush widget “upload.zip”

Authentication Module with E-mail & Image Verification!

Aug 1, 2008   //   by nuhil   //   HTML, JS, MySQL, PHP  //  1 Comment

I’ve built an authentication system which can be used as secured module in a registration form or in a suggestion box where there are probability of insertion of data by a robot script. By using the image verification fact no auto generated script can fill up a form. Other wise there is an e-mail verification fact by which the man who fill up the form giving his e-mail address should check up his inbox for the mail sent by the form.
The e-mail is sent with a link on which by clicking it executes a script for neccessary update in the database.


In this module when a user fill up the form then in database every data is inserted and in a filled named active ’0′ is inserted. When the user clicks on the link sent to him by e-mail. It then executes another script page which then updates the value of active field into ’1′.
Then you can verify a user by examining the value of his active field in database that ensures that he clicked on th link.
This can be used as module in any Webapp.

See the example: Register Login

You can download the source code from the ShareBox left of side of my site. named Auth.zip

My 5th Semester Project!

Jul 29, 2008   //   by nuhil   //   CSS, HTML, My RUET life, MySQL, PHP  //  No Comments

I have launched my 5th semester project on the web for testing and further feedback. I was directed to make a web app for a garments shop. There are two types of use. Administrator can upload a product by specific privilege and customer can see required product or all product by searching with requirements. They also can by the product.

The address: My project

Another Power of Ajax! Instant Edit on View-Page

May 1, 2008   //   by nuhil   //   Ajax, CSS, JS, MySQL, PHP  //  2 Comments

When a page is displayed with requested data from a database, then normally the data it contains can be edited or updated by getting the id of that form and by using that to update the form. Now, with the Ajax you can make a output page where you can edit the field of the form by just clicking on it and it will be saved to database instantly.

I’m unable to describe the benifit or beauty of this task. Just try it and make it more effective and do the JavaScript and be with Ajax. Example named insedit.zip

Feelings of Drag and Drop using Ajax-PHP-MySQL

Apr 21, 2008   //   by nuhil   //   Ajax, JS, Library, MySQL, PHP  //  1 Comment

Refference -Building Responsive Web Application by PACKT PUBLICATION

You Just try this example and feel the power of Ajax and the libraries just like Script.aculo.us , prototype.js . Recently, Web Application without attractive interface is not accepted to real users. So, use the maximum of Libraries and Frameworks.

 You can get this example in my Shared Box named dragdrop.zip

Pages:12»