我有一个帖子php页面,一旦数据发布到数据库,我希望它将用户重定向到新页面,并显示刚刚插入的记录的last_id的结果。
我可以很好地验证数据帖子,但重定向不起作用。它只是坐在那里看起来很伤心。它工作过一次,但现在我似乎无法让它重新开始工作。
有问题的片段是:
oauth2-oidc-test-server
整个脚本是:
qt.network.ssl: QSslSocket: cannot resolve CRYPTO_free
qt.network.ssl: QSslSocket: cannot resolve EVP_CipherFinal
qt.network.ssl: QSslSocket: cannot resolve EVP_rc2_cbc
qt.network.ssl: QSslSocket: cannot resolve SSLv2_client_method
qt.network.ssl: QSslSocket: cannot resolve SSLv2_server_method
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_add_all_algorithms_noconf
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_add_all_algorithms_conf
qt.network.ssl: QSslSocket: cannot resolve EC_get_builtin_curves
qt.network.ssl: QSslSocket: cannot call unresolved function OPENSSL_add_all_algorithms_conf
qt.network.ssl: QSslSocket: cannot call unresolved function EC_get_builtin_curves
qt.network.ssl: QSslSocket: cannot call unresolved function EC_get_builtin_curves
答案 0 :(得分:1)
如果您在响应标头中返回重定向,我认为您会得到更好的结果......
header( 'Location: http://vmcnucmed.cvm.umn.edu/patientinjection/view_inj_info.php?id=' . $last_id );
答案 1 :(得分:1)
发布后重定向的最佳做法是发送包含302状态代码的Location标头,而不是使用HTML元标记重定向:
header(
'Location: http://vmcnucmed.cvm.umn.edu/patientinjection/view_inj_info.php?id=' . $last_id,
TRUE, // rewrite existing Location header
302 // set status code
);
302代码将强制浏览器使用GET而不是POST请求重新加载页面。