Hi all.
I have a guestbook im making. Im not much of a coder yet, its actually my first real attempt to make something useful in php & MySQL.
I got a simple insert and display data from a MySQL script working fine, but the problem is, when i write a link in a textarea: hxxp://www.google.com, it displays as text when i output it from my MySQL table.
I want the users of the guestbook to just write an url without having to use the html
<a> tag. So when writing an url, it automatically displays as a link on the output.
My form looks like this:
Code:
<form action="insertcomment.php" method="post" name="post">
<textarea name="comment" cols="53" rows="5" value="" /></textarea>
<br />
<input type="Submit" value="Post comment" class="button" />
</form>
The insert comment to MySQL file looks like this:
Code:
<?php
$_POST[comment] = mysql_real_escape_string(nl2br($_POST["comment"]));
$sql="INSERT INTO table_name(comment) VALUES ('$_POST[comment]')";
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
echo "<meta http-equiv='REFRESH' content='0;url=main.php'>";
echo "Success. <a href='main.php'>Go back</a>";
mysql_close($con)
?>
The database output file looks like this:
Code:
<?php
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$sql="SELECT * FROM table_name ORDER BY commentid DESC LIMIT 10";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){
echo $comment;
}
?>
If its something you dont understand of what i just said, then aim and fire questions at me.
Thanks in advance for any help