Insert <a> tag on input text field?

Hi guys

I’m trying to save the <a> tag on input ‘title’ text field into mysql database
I’m also using JQuery technology.

Here is the form below,
My programming Adventure…

So for example in the ‘Title’ field I entered a value like this below,
<a href=‘http://www.coder9.com’>Accordion</a> under JQuery category

Now when it showed on the index.php the format looks like this below,
My programming Adventure…

Sadly the entire texts turn into hyperlink and when you clicked the link
it redirect into wrong web address.

Anyone would like to give a hand on this.

Thanks in advanced.

$title=addslashes($_POST[‘title’]);
and then insert $title into database…

Here is the description of addslashes().
PHP: addslashes - Manual

@venkat thanks

But when I clicked the link it redirect me to the wrong address.
My programming Adventure…

can you just show me the code, from where you are getting the title and how to insert title into the database.?

Okay,

This is how I insert it,


//$conn = new mysqli('localhost', 'root', '', 'my_db');
$conn = new mysqli('localhost', 'coder9_work', '*******', 'coder9_portfolio');
$query = "INSERT into portfolio(category, title, description, version, started, finished) VALUES (?, ?, ?, ?, ?, ?)";

$title = addslashes($_POST['title']);

$stmt = $conn->stmt_init();
if($stmt->prepare($query)) {
	$stmt->bind_param('ssssss', $_POST['select'], $title, $_POST['description'], $_POST['version'], $_POST['started'], $_POST['finished']);
	$stmt->execute();
}

And this is how I try to remove the slashes and show it,


		while ($db_field = mysql_fetch_assoc($result)) {
			$title = $db_field['title'];
			$title = stripslashes($title);
			echo "Title: " . $title . "<br>";

			echo "Description: " . $db_field['description'] . "<br>";
			echo "Version: " . $db_field['version'] . "<br>";
			echo "Started: " . $db_field['started'] . "<br>";
			echo "Finished: " . $db_field['finished'] . "<br><br>";
		}


Actually the insert is working fine.
I’m only having problem removing the slashes,
I already stripslashes() but unfortunately I don’t uderstand why it doesn’t work. You can see the codes above.

thanks again.

I noticed when I addslashes() it looks like this below,


<a href="\\\\\\'ball.com\\\\\\'">ball</a>

Why there are three slashes in each quote?


<?php
$title="<a href='http://www.coder9.com'>Accordion</a>";
echo $title.'<br/>';

$dbconn1=mysql_connect($server,$username,$password) or die('Invalid Query: '. mysql_error());
mysql_select_db($database,$dbconn1) or die('Invalid Query: '. mysql_error());
$title=addslashes($title);

//for insertion
$query1 = "INSERT into table_name values ('$title')";
$result1=mysql_query($query1,$dbconn1)or die('Invalid Query: '. mysql_error());

// for retrive
$sql = "SELECT * FROM table_name where id='record number'";
$result = mysql_fetch_array(mysql_query($sql));
echo $result['title'];