Originally posted by getphp
Can someone explain this code to me please.. I seem to be strugglin understanding this 'Heavy' code
If $do=='add' (and personally I suspect that this may be a mistake, depending on where $do is supposed to be coming from, but anyway)....
A bunch of lines that take a bunch of form variables and (at a guess, since I haven't seen mhtml()) cleans them up to prevent malicious users inserting stuff that could cause damage later.
Then it looks to see if any of those variables are empty. If any are, it creates a list item (the text of which is stored in an array called $LANG - that would be to allow internationalisation) and appends it to the $error variable. (Incidentally, the HTML generated by this step looks invalid, but whatever...)
If $error is still empty after the previous step, then there were no errors.
Dunno where $cat came from, but it appears to contain stuff about whether to send an email and what headers to give it (and no doubt other configuration-type stuff as well). If an email is wanted, then one is built and sent, containing the $title and $url of the page entered in the form.
Whether an email was wanted or not, the form information is stuck in a database ( and using "or die(mysql_error())" is not good practice in production code, but again, whatever...)
The script then immediately tries to find the record just entered, and gets the id number for it. (This is frankly buggy, as it assumes that every URL will be unique, and besides, there is a function to do the job: [man]mysql_insert_id[/man]. But....)
So it takes that ID and spits out a wee HTML page that just redirects the user to a thank you page, with the ID added (presumably so the thank-you page knows which page to thank the user for). Why header() wasn't just used I don't know.
Then the script ends.
After that comes whatever code is to be run if there (a) is an error or (b) $do didn't equal "add".
So the short answer is that it looks like it accepts and records users' recommended links.
[edit: and wow, because of the really long and unformatted SQL query there, every single paragraph I wrote fits on one line!]