Some how i been involved in creating few parts of http://www.hottdogzzbikinizz.com 😉 .
well i know what ya thinking , but its not like that *grin grin*…

One of the features i Developed was the JPG upload function [did’nt involve Mysql] …
what simply happens when you first submit the form it will check if you did’nt forget any field .
It will also check wether the submitted image is a JPEG/PJPEG otherwise it wont accept it …

the 2nd step is to process the uploaded image , Creates a folder with name-age-location of the submiter and stores the images in it.

3rd step is to send an email to the admin with all the user details , Image Location , and the actual Location( by ip ) of the submitter .

almost 300 lines of code ….

now lets see one of the examples :
imagine we want to create a folder for every user using his Name Age and Location assuming we already extracted the posted values into variables …

    $name
    $age
    $loc

$success = mkdir($name."-".$age."-".$loc,0777)
if(!$success) {

exit(‘something went wronge’);
}

this is ok , but what if i want to use the above code more than 100 times ?!
Copy & Paste …. ?
No ..

Lets see how can we make that re-usable …


function MakeDir($n,$a,$l) {$success = mkdir($n.”-“.$a.”-“.$l,0777);
if(!$success) {

exit(‘something went wronge’);
}
}

Now we can use that 1000 time with few lines of code ..
here is how …

MakeDir($name,$age,$loc);
MakeDir($name2,$age2,$loc3l);

//you can use a loop like [ foreach ( $x as $y ) etc …. ]

hope this was usefull …
now remember ..

Practice makes Perfect ...
🙂