test
Hi all, I have a guestbook, which is inserted into my database, and im trying to strip the html, js etc from it before it is inserted, atm anyone can insert code into my database, which is well, rather bad, I currently have the following code, however it does nothing but insert into my database like normal:
Hi all, I have a guestbook, which is inserted into my database, and im trying to strip the html, js etc from it before it is inserted, atm anyone can insert code into my database, which is well, rather bad, I currently have the following code, however it does nothing but insert into my database like normal:
Code:
<?php
$sel = mysql_connect("localhost","cpanelu_dci125","MonkeyTeaPot");
if (!$sel)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("cpanelu_dci125", $sel);
strip_tags ($_POST[name]);
strip_tags ($_POST[email]);
strip_tags ($_POST[comment]);
$dat="INSERT INTO guestbook (name, email, comment)
VALUES ('$_POST[name]','$_POST[email]','$_POST[comment]')";
if ($_POST['name'] == NULL)
{
die('Please Do Not Leave Any Field Blank, You Will Now Return To The Guestbook!');
}
elseif ($_POST['email'] == NULL) {
die('Please Do Not Leave Any Field Blank, You Will Now Return To The Guestbook!');
}
elseif ($_POST['comment'] == NULL) {
die('Please Do Not Leave Any Field Blank, You Will Now Return To The Guestbook!');
}
if (!mysql_query($dat,$sel))
{
die('Error: ' . mysql_error());
}
echo "Thank you for leaving a comment! You will return to the guestbook shortly";
mysql_close($sel)
?>
Last edited: