Jump to content

[SOLVED] Disabling HTML in INPUT and TEXTAREA


tomcommathe

Recommended Posts

Title says it all, I am hoping to disable all HTML tags in a form (eventually adding in BBC-Style codes for basic options like bold and images and the like)

 

Post Code:

<?
$username="username";
$password="password";
$database="database";

$name=$_POST['name'];
$email=$_POST['email'];
$subject=$_POST['subject'];
$date=$_POST['date'];
$time=$_POST['time'];
$news=$_POST['news']


mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = 
$query = "INSERT INTO newsupdate VALUES ('','$name','$email','$subject','$date','$time','$news')";
mysql_query($query);

mysql_close();

header('Location:URL');

?>

 

The Form Code:

<div id="form">
<form action="updatenews.php" method="post">
Name: <input type="text" name="name"><br><br>
E-mail: <input type="text" name="email"><br><br>
Subject: <input type="text" name="subject"><br><br>
News Update:<br>
  <textarea name="news" rows="4" cols="26"  /></textarea> <br /><br>
  <input type="Submit" value="Submit News!">
<input type="hidden" name="date" value="<? echo date('F j, Y'); ?>" />
<input type="hidden" name="time" value="<? echo date('h:i'); ?>" /
</form>
</div>

 

Thanks for any help!

Wah wha wha....

 

Maybe I did something wrong, but I don't know...

This is a Paragraph that has become bold!

Warning: Cannot modify header information - headers already sent by (output started at /home/mijunkin/public_html/mopedstl/phpTest/newsUpdate/updatenews.php:14) in /home/mijunkin/public_html/mopedstl/phpTest/newsUpdate/updatenews.php on line 26

 

Updated Code (but putting an echo in there doesn't seem right since I am trying to write to MySQL Database. ::

<?
$username="username";
$password="pwd";
$database="database";
$bar = strip_tags($news);

$name=$_POST['name'];
$email=$_POST['email'];
$subject=$_POST['subject'];
$date=$_POST['date'];
$time=$_POST['time'];
$news=$_POST['news'];
$bar = strip_tags($news);
echo $bar;


mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = 
$query = "INSERT INTO newsupdate VALUES ('','$name','$email','$subject','$date','$time','$news')";
mysql_query($query);

mysql_close();

header('Location:http://mopedstl.com/phpTest/newsUpdate/');

?>

Problem solved! What I ended up doing was...

 

<?
$username="user";
$password="pword";
$database="database";


$name=$_POST['name'];
$email=$_POST['email'];
$subject=$_POST['subject'];
$date=$_POST['date'];
$time=$_POST['time'];
$news=strip_tags($_POST['news']);

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT INTO newsupdate VALUES ('','$name','$email','$subject','$date','$time','$news')";
mysql_query($query);

mysql_close();

header('Location:http://mopedstl.com/phpTest/newsUpdate/');

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.