我有一个注册页面(index.php)。它需要两个值“用户名”和“密码”,并且使用这些值的数据库更新发生在 registrartion.php 页面上。我希望代码在更新我的数据库后将registration.php页面重定向到index.php页面,同时显示您已成功注册的消息。在这方面提供帮助。谢谢
注册.php
<?php
$host="l888888"; // Host name
$username="******"; // Mysql username
$password="t******"; // Mysql password
$db_name="f****"; // Database name
$tbl_name="m******"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['username'];
mypassword=$_POST['password'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$query=mysql_query("INSERT INTO members(`username`,`password`) VALUES ('$myusername','$mypassword')");
if($query)
header('Location: /home/faltutal/public_html/treasurehunt/index.php');
?>
如果我使用 header('Location:index.php')
错误显示无法修改标头信息 - 标头已发送(输出开始于 /home/faltutal/public_html/treasurehunt/registration.php:2)