Php $\u在同一页面内发布链接
我正在尝试将结果显示在同一页面上,而不必创建.php页面并将结果显示在单独的页面上。这是一个应用程序,用户可以提交任何类型的链接,并将结果显示在页面上 有没有办法把结果保存起来供以后参考?刷新页面时是否保持显示结果Php $\u在同一页面内发布链接,php,jquery,css,sql,ajax,Php,Jquery,Css,Sql,Ajax,我正在尝试将结果显示在同一页面上,而不必创建.php页面并将结果显示在单独的页面上。这是一个应用程序,用户可以提交任何类型的链接,并将结果显示在页面上 有没有办法把结果保存起来供以后参考?刷新页面时是否保持显示结果 <!doctype html> <html> <head> <meta charset="UTF-8"> <title>PHP links</title> <?php echo '<div styl
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>PHP links</title>
<?php
echo '<div style="background-color:#ccc; padding:20px">' . $_POST['message'] . '</div>';
?>
<style type="text/javascript">
// prepare the form when the DOM is ready
$(document).ready(function() {
// bind form using ajaxForm
$('#htmlForm').ajaxForm({
// target identifies the element(s) to update with the server response
target: '#htmlExampleTarget',
// success identifies the function to invoke when the server response
// has been received; here we apply a fade-in effect to the new content
success: function() {
$('#htmlExampleTarget').fadeIn('slow');
}
});
});
</style>
</head>
<body>
<form id="htmlForm" action="html-echo.php" method="post">
Display List of Links <input type="text" name="message" value="Hello HTML" />
<input type="submit" value="Submit links" />
</form>
</body>
</html>
?>
您生成的result.php结果将显示在index.php上,而无需重新加载或重定向页面您可以通过AJAX发送表单来使用$\u会话。您暗指结果。结果是什么?可以帮你解决这样的问题。
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>PHP links</title>
<?php
echo '<div style="background-color:#ccc; padding:20px">' . $_POST['message'] . '</div>';
?>
<script type="text/javascript">
$(document).ready(function() {
$('#formid form').submit(function(){
$.get('result.php', $(this).serialize(), function(data){
$('#result').html(data);
});
return false;
});
});
</script>
</head>
<body>
<div id="formid">
<form>
Display List of Links <input type="text" name="message" value="Hello HTML" />
<input type="submit" value="Submit links" />
</form>
</div>
<div id="result"></div>
</body>
</html>
<?php
$message=$_REQUEST['message'];
echo $message;