gpt4 book ai didi

PHP 运行脚本,完成后重定向

转载 作者:行者123 更新时间:2023-11-29 18:45:40 26 4
gpt4 key购买 nike

在 PHP 中,一旦脚本成功运行并成功案例 0,如何重定向我的页面,但仍保留在当前页面上执行其他操作?

exec( $command, $output = array(), $worked );

switch( $worked ) {

case 0:
echo "Database <b>". $database. "</b> successfully exported to <b>". $filename. '</b>';
// add redirect here
break;

case 1:
echo 'There was a warning during the export of <b>'. $database .'</b> to <b>'. $filename .'</b>';
break;

case 2:

echo 'There was an error during import.'
. 'Please make sure the import file is saved in the same folder as this script and check your values:'
. '<br/><br/><table>'
. '<tr><td>MySQL Database Name:</td><td><b>'. $database .'</b></td></tr>'
. '<tr><td>MySQL User Name:</td><td><b>'. $user .'</b></td></tr>'
. '<tr><td>MySQL Password:</td><td><b>NOTSHOWN</b></td></tr>'
. '<tr><td>MySQL Host Name:</td><td><b>'. $host .'</b></td></tr>'
. '<tr><td>MySQL Import Filename:</td><td><b>'. $filename .'</b></td>'
. '</tr></table>'
;
break;
}

最佳答案

如果您不介意在重定向之前删除“echo”,您可以使用 header 进行重定向

 header("Location: http://you-url");

如果没有,你可以使用javascript

<script> window.location = "http://your-url"; </script>

您可以添加一些内容来延迟重定向,或者在重定向之前将“已成功导出”消息置于提醒中,否则如果重定向速度太快,用户可能看不到该消息。

关于PHP 运行脚本,完成后重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44676614/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com