1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP/MySql CMS link question.

Discussion in 'PHP' started by sam chaos, Aug 17, 2005.

  1. #1
    hi,

    i've made a simple PHP news page by follwing the tutorial here: http://www.greycobra.com/tutorials.php?tutorial=view&id=53
    SEMrush
    It all works fine but for the purpose i need it for I would like to be able to type links within the message section of the 'submit.php' page. As it is at present when i type in the HTML code to link to an external site the resulting executed 'viewnews.php' does have the link but it adds my site root to the beginning of the links i have entered. For example if i type:
    '<a href="http://www.google.com">google</a>' into the message text area on the 'submit.php' page it results in a link to
    'http://vbsdesign.co.uk/\http://www.google.co.uk\'.

    If i haven't explained this very well it might be best to view the files....
    http://www.vbsdesign.co.uk/submit.php
    http://www.vbsdesign.co.uk/viewnews.php

    If you haven't noticed i'm very new to PHP, and therefore this is probably something very simple.

    hope someone can help.
    thanks.

    ps..sorry. the forum won't allow me to make 'live' links yet as this is my first post so a bit of cutting and pasting may be needed!
     
    sam chaos, Aug 17, 2005 IP
    SEMrush
  2. goldensea80

    goldensea80 Well-Known Member

    Messages:
    422
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    128
    #2
    I see the problem
    It all concern two PHP functions: addslashes and stripslashes
    It is recommended that use always use addslashes when insert to a database.
    In this case, the PHP config is set up do do this part for you. But you should know this in other server. Otherwise, this may lead to security hole.

    With your case, you can use stripclashes to remove the slashes (\)
    E.g.
    
    <?php
    $str = '<a href=\"http://php4u.blogspot.com\">http://php4u.blogspot.com</a>';
    // Outputs: <a href="http://php4u.blogspot.com">http://php4u.blogspot.com</a>echo stripslashes($str);
    ?> 
    
    PHP:
     
    goldensea80, Aug 18, 2005 IP
  3. Connect

    Connect Guest

    Messages:
    191
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Have to see the php coding of submit.php and/or viewnews.php to be sure what is the cause of the problem.
     
    Connect, Aug 18, 2005 IP
  4. goldensea80

    goldensea80 Well-Known Member

    Messages:
    422
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    128
    #4
    Sorry, the demo code has some mistake:
    It should be like this;
    
    <?php
    $str = '<a href=\"http://php4u.blogspot.com\">http://php4u.blogspot.com</a>';
    // Outputs: <a href="http://php4u.blogspot.com">http://php4u.blogspot.com</a>
    echo stripslashes($str);
    ?> 
    
    PHP:
     
    goldensea80, Aug 18, 2005 IP