forms and php
Posted: Wed Jan 16, 2008 11:41 am
Everah | Please use the bbCode tag [code] when posting code in the forums. For posting PHP code, use [code=php].
i am using freerte editor for my website ,i got this from the following url http://www.reerichtexteditor.com/
i am trying to pass that text the user enters in the rte to my mysql db, but i am having problems. this is my code
i am using echo("javascript:alert('$temp');"); just to check that the text is retrieved when i click submit. Any help would be appreciated.
Everah | Please use the bbCode tag [code] when posting code in the forums. For posting PHP code, use [code=php].
i am using freerte editor for my website ,i got this from the following url http://www.reerichtexteditor.com/
i am trying to pass that text the user enters in the rte to my mysql db, but i am having problems. this is my code
Code: Select all
<html>
<head>
<title>My first MySQL form submission</title>
</head>
<body>
<?php
$conn = @mysql_connect("localhost", "*****", "*****");
if (!@mysql_select_db("info", $conn))
die("<p>Error selecting DB-DEVEL database: <i>" . mysql_error() . "</i></p>");
?>
<?php
function send_data(){
$date=date("Y")."-".date("m")."-".date("d");
$time=date("G").":".date("i").":".date("s");
$max_query = "SELECT MAX(number) FROM blog";
$max_result = mysql_query($max_query);
while ($property = mysql_fetch_array($max_result))
{
$number = ($property["MAX(number)"]);
}
$number=$number+1;
$user="thomas";
$comments="0";
$year=substr(date("Y"),2,2);
$month=date("m");
$day=date("d");
$temp=$_GET['blog_content'];
echo("javascript:alert('$temp');");
// mysql_query("INSERT INTO blog (blog_date,blog_content,poster,time,comments,number,month,day, year) VALUES ('$date','$blog_content','$user','$time','$comments','$number','$month','$day','$year')");
//mysql_query("INSERT INTO blog (blog_date, blog_content, poster, time, comments, number, month, day, year) VALUES //('$date','$blog_content','$user','$time','$comments','$number','$month','$day','$year')");
}
?>
<!-- Include the Free Rich Text Editor Runtime -->
<script src="rte/js/richtext.js" type="text/javascript" language="javascript"></script>
<!-- Include the Free Rich Text Editor Variables Page -->
<script src="rte/js/config.js" type="text/javascript" language="javascript"></script>
<!-- Initialise the editor -->
<script>
initRTE('this is just some preloaded content, this is just a test tp see where the string will fit and is it fits correctly');
</script>
<form action="" method="get">
<INPUT type="hidden" NAME="blog_content" VALUE="getXHTML(trim(document.getElementById(rteFormName).value));">
<input type="submit" name="submit" value="Submit!" onclick="<?php send_data();?>">
</form>
<?php
mysql_close ($conn);
?>
</body>
</html>i am using echo("javascript:alert('$temp');"); just to check that the text is retrieved when i click submit. Any help would be appreciated.
Everah | Please use the bbCode tag [code] when posting code in the forums. For posting PHP code, use [code=php].