Jump to content

php submit link problem


dsjoes

Recommended Posts

when i upload a link using the form below it adds \ into it like this <a href=\"http://www.google.co.uk\" target=\"_blank\">test</a> and the link is unusable with them any way to stop this

 

<?php
include("dbinfo.inc.php");
mysql_connect($localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM News WHERE id='$id'";
$result=mysql_query($query);
$num=mysql_numrows($result); 
mysql_close();

$i=0;
while ($i < $num) {
$News=mysql_result($result,$i,"News");


?>
<form action="updated.php">
<input type="hidden" name="ud_id" value="<? echo "$id"; ?>">
News:<br> <TEXTAREA NAME="ud_News" COLS=40 ROWS=6><? echo "$News"?></TEXTAREA><br>
<input type="Submit" value="Update">
</form>

<?php
++$i;
} 
?>

Link to comment
Share on other sites

OK, when you insert the values into the database, are you using any logic strip out the slashes added by magic_quotes_gpc before using mysql_real_escape_string? If you don't, the data ends up doubly escaped resulting in a set of the slashes making its way into the database.

 

Should look something like this for sanitizing and inserting the data:

if( get_magic_quotes_gpc() ) {
     $value = mysql_real_escape_string(stripslashes($_POST['value']));
} else {
     $value = mysql_real_escape_string($_POST['value']);
}

Link to comment
Share on other sites

OK, when you insert the values into the database, are you using any logic strip out the slashes added by magic_quotes_gpc before using mysql_real_escape_string? If you don't, the data ends up doubly escaped resulting in a set of the slashes making its way into the database.

 

Should look something like this for sanitizing and inserting the data:

if( get_magic_quotes_gpc() ) {
     $value = mysql_real_escape_string(stripslashes($_POST['value']));
} else {
     $value = mysql_real_escape_string($_POST['value']);
}

thanks that has worked

Link to comment
Share on other sites

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.