Forum Moderators: open

Message Too Old, No Replies

wysiwyg editor submission issue.

wysiwyg editor submission to database issue.

         

aftershock2020

6:33 am on Oct 1, 2009 (gmt 0)

10+ Year Member



I have a wysiwyg editor that I built by an open source script as the base example. As an editor, it works great but it doesn't allow for submission to the database because I can't figure out how to set the var as it is into the database.

It was only an editor, not a full app as I am attempting to flesh it out to be.

Here is the form that I have with it so far, modified ofcourse:

<form name="Blog_post" onSubmit="editor1.prepareSubmit()" method="post">
<p><b>Title:</b>
<input type=text name="title" id="post_title " size="40">
</p>
<p> Type or paste your message below:</p>
<?php echo"<script type='text/javascript'>
var editor1 = new WYSIWYG_Editor('editor1');
editor1.display();
</script>
"; ?>
<input type="hidden" name="post_date" value="<?php echo '$timestamp'?>">
<br>

<input type="submit" name="Submit" value="Post Blog">
</p>
</form>

Here is the second form from the edit file to update the information from the previous form:

<form name="Blog_edit" onSubmit="editor1.prepareSubmit()" method="post">
<p><b>Title:</b>
<input type=text name="title" size="40">
</p>
<p> Type or paste your message below:</p>
<?php echo"<script type='text/javascript'>
var editor1 = new WYSIWYG_Editor('editor1','<?php echo '$content' ?>');
editor1.display();
</script>
"; ?>
<input type="hidden" name="sub date" value="<?php echo '$timestamp'?>">
<br>

<input type="submit" name="Submit" value="Post Blog">
</p>
</form>

I have a content variable as saving the data in the body of the editor but, as you can see, I don't know what nor where to call the submission from the editor to push the data to the database.

Can someone please advise how to connect these to my database on pass of the submit button?

I am trying to use this form for me own article posting script for a project.

whoisgregg

2:34 pm on Oct 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When you are echoing a variable, you can't have it wrapped in single quotes or else it won't parse the variable data:

<?php echo $content; ?>

Also, where is the $content variable being set? I think you'll want to have something like this higher up in the script:

<?php
$content = addslashes(preg_replace('`[\r\n]`','\n',$_POST['editor1_content']));
?>

As far as how to access posted variables, the best thing to do is to add this line to your code for debugging so you can see what's being posted:

<?php print_r($_POST); ?>

HTH :)