Hi. Thanks for reading. I am looking for an explanation of how to treat a Link to a website when I capture it as a input field.
I have an input text field Link: ................... The profile creator can type in an HTML link "http://www.yahoo.com". ( Or a more complex link, possibly to his Facebook page, or Instagram or Twitter.) Once she types it in and submits it, Javascript reads the input and saves it as variable which is passed to PHP where it is saved in a MySQl column. On the user page, this link will then be read from the database and echoed out as an <a> anchor tag around the profile, allowing others to cllick on the link and direct the end user to the site added by profile creator.
Can someone please spell out what steps I should take?
1. What validation on the quality of the link be done? (if the user typed in 'Hello World'....can I detect this and reject it?) Can I test that it starts with HTTP:, etc. Any ideas appreciated.
2. I assume javascript should then capture the link with encodeURI()?
3. On the PHP side, I will have the encoded URI...Can that be written directly to the MYSQL? Will PHP urldecode() suffice to recreate the string when it is echoed as an <a> tag?
Thanks for your feedback, or any pointing to a good explanation or reference!