Jump to content

AJAX / Javascrpt / PHP overview of Links and treating them as a variable


Recommended Posts

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 by jamfitz001
grammar

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.