我正在使用包含此代码的index.php页面
<form action="post.php" method="POST">
<textarea placeholder="write something.........." name="desc" "></textarea>
<input type='submit' name='post' value='POST' />
<form>
然后当我点击index.php
中的提交按钮时,会将我链接到pos.php
if(isset($_POST['post'])){
$description=$_POST['desc'];
$sql = "INSERT INTO post(description) VALUES('$description')";
if(mysqli_query($con,$sql)){
//i need to get another third php file which automaticaly load when you click the submit butto in the idex.php
<a href="third.php">third Page</a>
}
else{
echo 'failure'.mysqli_error($con);
}
当我尝试这个它使我链接比第三个PHP,但我不想要那个 我想同时将数据插入到sql中,将我链接到第三页,而不是点击任何其他链接
任何人都可以帮助我
谢谢!
答案 0 :(得分:0)
会包括做你想要的吗? http://php.net/manual/en/function.include.php
include('third.php');
这会将third.php中的所有代码添加到你的post.php中,并加载它的内容。
答案 1 :(得分:0)
如果我理解您的要求,则需要在将数据保存到数据库后进行重定向。
html表格:
<form action="do_something.php" method="post">
<textarea placeholder="write something.........." name="desc" "></textarea>
<input type='submit' name='post' value='POST' />
<form>
do_something.php:
<?php
/*
* Do your sql;
* use prepared statements; see http://php.net/manual/en/mysqli.quickstart.prepared-statements.php
* you'll have to look this up to implement it
*
* $sql = "INSERT INTO post(description) VALUES(?)";
*
* bind value and execute.
*/
/*
* Note; there must be NO output before the header call!
*/
$newUrl = "http://yourDomain/third.php";
header('Location: '.$newURL);
die;
third.php
// page 3 loads immediately after do_something.php executes.
当您按照此模式操作时,后退按钮不会重新提交您的POST数据。