htaccess to handle redirect page when url encodeURIComponent

ぃ、小莉子 提交于 2020-01-05 03:43:32

问题


I have a page that uses TinyMCE to update the contents of the web. when I click the button on the form with ajax post method, I get the contents of my url like this (http://vansolusindo.com/demo2/lapakkemasan/test/test.php?v_content=%3Cp%3Etest+update+data%3C% 2Fp% 3E & save = Submit).

then immediately redirect to the index page of my website. so it makes no .php file for input to the database. My question, how to handle that my page is not redirect to the index page and enter .php pages to insert into the database.

  • I've been looking on the internet, there seems to be a setting for his .htaccess file.

The following script .php and my .htaccess.

script test.php:

<!DOCTYPE html>
<html>
<head> 
<script>
 function umce(){ 
    tinyMCE.triggerSave()
    }; 
 function ut(){   
    $.ajax({  
        cache: false,
        type:'POST', 
        url:'save.php',  
        data:"text="+encodeURIComponent(tinyMCE.activeEditor.getContent()), 
        success: function(data){
                alert(1);
        }
    }); 
    return false; 
};
</script>    
<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
<script>tinymce.init({ selector:'textarea' });</script>
</head>
<body>
<form onsubmit='umce();ut(); return false;'>
<textarea id="v_content" name="v_content"></textarea>
<input type="submit" name="save" value="Submit" />
</form>
</body>
</html>

save.php :

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
    die('Could not connect: ' . mysql_error());
}
mysql_select_db("lapakkemasandb");
$sql="UPDATE t_modules SET content=('$_POST[v_content]') WHERE id_t_modules='3'";
if (!mysql_query($sql,$con))
{
    die('Error: ' . mysql_error());
}
echo "success to update"; 
mysql_close($con) 
?>

.htaccess :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php 

Please help me, I've been dizzy =( =( =(

来源:https://stackoverflow.com/questions/39952486/htaccess-to-handle-redirect-page-when-url-encodeuricomponent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!