Search code examples
javascriptphphtmlcsshref

Allow user to add a new link to their website?


Question

How could i allow a user to add a new link to an already existing list of links permanently. Preferably the new link would be written directly to the HTML document without the need for a database to store the links, if possible.

I do not want to use a Content Management System like, WordPress as i feel this negates any possibility of learning how to do such tasks and breeds laziness. (My opinion)

Background

I am creating a website for someone, who i would like to be able to update parts of their website without my help.

All they need to be able to do is add a new link to a current list of links on one web page. The page is protected and only accessible to them once a secure password is entered.

This is how the links are displayed, all i would need is, for a new link to be appended to the bottom and saved permanently to the html page.

enter image description here

Markup

<div class="content">
  <div id="media">
    <h3>Clients</h3>
    <h2><a href="http://www.purplegeckoevents.com">Purple Gecko Events</a></h2>
    <h2><a href="http://www.plymouthvolksfest.co.uk/">Plymouth Volksfest</a> </h2>
    <h2><a href="http://moriaty.co.uk/">Moriaty</a> </h2>
    <h2><a href="http://www.landofthegiantsmusic.co.uk/">Land of the Giants</a> </h2>
    <h2><a href="https://www.facebook.com/betamaxlive">Betamax</a> </h2>
    <h2><a href="https://www.facebook.com/hauntthewoodsofficia">Haunt the Woods</a></h2>
    <h2><a href="http://www.minglemusic.co.uk/">Mingle Music Agency</a> </h2>
  </div>
</div>

Solution

  • You will need a db to store all these links.

    And then you can :

    1. To display links - use php to fetch all the links from db and show them. http://www.w3schools.com/php/php_mysql_select.asp
    2. To add links - use form to take input of link(the href,title etc) and insert in db http://www.w3schools.com/php/php_mysql_insert.asp