Page 1 of 1
PHP/MYSQL/HTML
Posted: Thu May 20, 2004 6:45 pm
by AlbinoJellyfish
I want to input html code in a box, use post to send to mysql, then call it up and display what the page would look like if I had just used html. When I enter the code, the Html tags get removed... How do I keep them?
Posted: Thu May 20, 2004 6:48 pm
by feyd
show your code.
Posted: Thu May 20, 2004 6:53 pm
by AlbinoJellyfish
Code: Select all
<html>
<head><title>Add News</title></head>
<body>
<?php
$db = mysql_connect("localhost", "not tellin","not tellin");
mysql_select_db("announcements",$db);
// query the DB
$sql = "SELECT * FROM news";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form method="post" action="addnewsp.php">
<input type=hidden name="id" value="<?php echo $id ?>">
Date:<input type="Text" name="date" value=""><br>
Description:<input type="Text" name="description" value=""><br>
Story:
<br><TEXTAREA NAME="story" ROWS="8" COLS="48">Type your story here</TEXTAREA> <br>
Link to:<input type="Text" name="link" value=""><br>
<input type="Submit" name="submit" value="Enter information">
</form>
<?php
mysql_close($db);
?>
</body>
</html>
This is POST page:
Code: Select all
<html><head><title>Adding News</title></head>
<body>
<?
$id=$_POST['id'];
$date=$_POST['date'];
$description=$_POST['description'];
$story=$_POST['story'];
$link=$_POST['link'];
$db = mysql_connect("localhost","mattmooers","minnetonka");
mysql_select_db("announcements",$db);
if (! $db)
die("Couldn't connect to MySQL");
mysql_query(" INSERT INTO news (date,description,link,story) VALUES ('$date','$description','$link','$story')");
echo "News Added";
mysql_close($db);
?>
</body>
</html>
Posted: Thu May 20, 2004 6:59 pm
by feyd
what's the structure of the table news?
In your insertion page, add this:
Code: Select all
echo nl2br(htmlentities($story,ENT_QUOTES));
somewhere after $story is set.. and see if the data is posting correctly..
Posted: Thu May 20, 2004 7:07 pm
by AlbinoJellyfish
Hmmm, now when it posts, it works...
Posted: Thu May 20, 2004 7:15 pm
by feyd
k.. so move on to looking directly into the database with whatever you have as an interface program for it.. if you have one..
next step beyond that is making sure the output has html in it.. with exactly the same echo I have above.. but getting the story from the database..
How are you accessing the data? Can I see that code?