jamfitz001 Posted February 27, 2019 Share Posted February 27, 2019 (edited) 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! Edited February 27, 2019 by jamfitz001 grammar Quote Link to comment https://forums.phpfreaks.com/topic/308403-ajax-javascrpt-php-overview-of-links-and-treating-them-as-a-variable/ Share on other sites More sharing options...
requinix Posted February 27, 2019 Share Posted February 27, 2019 1. Look at PHP's filter functions. 2. No? The "link" is just text. Like any other text. 3. Now that you aren't encoding it, don't decode it. Yes, store it in your database (using proper procedures). Go ahead and implement it, then post what you did and we'll look over it. Quote Link to comment https://forums.phpfreaks.com/topic/308403-ajax-javascrpt-php-overview-of-links-and-treating-them-as-a-variable/#findComment-1564900 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.