Topic: URL format check
I don't know PHP...
I want to use this trick from profile.php in another file, to check if the submitted URL has http:// and add it if it doesn't before inserting it into the database.
if ($form['url'] != '' && strpos(strtolower($form['url']), 'http://') !== 0)
$form['url'] = 'http://'.$form['url'];
I've found this that presumably does the same thing:
if (strstr($new_url, 'http://')===false)
$new_url = 'http://'.$new_url;
Neither work by themselves. Nr1 needs other parts from profile.php and it's not clear to me where to put these pieces of code in my file. I've tried different things.
I searched all over the internet for other examples of forms with a URL field where the URL format is checked. I couldn't find anything, nothing that was transparant enough to reverse engineer for someone who doesn't know PHP anyway.
Any suggestions, clues, pointers or examples are very welcome!