javascript - Edit a page with content editable and save it using php -


i trying wrap head around project work on attempt more familiar programming in php.

i want create website that's easy update without full blown cms. thinking of using html5 contenteditable widget.

what envision following:

  1. user logs in , session started allow php echo content editable tag it's visible when user authenticated.
  2. once logged in, user can make changes file , click save button , file updated. need help

is possible update php file on? if is, involve ajax or pure php? how pass content within contenteditable widget saved on server? don't want use ftp i'm assuming have learn how ajax? hate ask if have example code awesome!

lastly, super major security risk?

thanks in advance!

atlante

i did that. considering have built <form> has textbox , submit button:

<form action="update.php" method="post">   <div><label for="textarea">your message</label></div>   <div><textarea name="textarea" id="textarea"></textarea></div>   <div><input type="submit" value="save" /></div> </form> 

now need 1 thing. remove <form> , replace <textarea> contenteditable <div> this:

<strong>your message</strong> <div contenteditable id="textarea"></div> <input type="button" value="save" id="savebtn" /> 

as know, above acts rich text editor, need 1 thing. using jquery, post form using ajax , something:

$(function () {   $("#savebtn").click(function () {     var text = $("#textarea").html();     var url = "update.php";     $.post(url, {textarea: text}, function () {       $("#textarea").css("background", "#ccc").prop("contenteditable", false);       alert("thanks message!");     });   }); }); 

and answer question security, well, have have patched server , use https. has handled server side. modern browsers secure enough.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -