將數據庫中的執行頭函數插入數據庫後,在同一頁上提交表單後,在同一頁上提交表單&。但標題功能不起作用。這裏是我的代碼:php頭函數不能在表單數據接收頁面中工作
if ($err == null && isset($_POST['regsignup']) == 'Register') {
$user->addUser();
#its the data inserting function on database
header("location:login.php?register=true");
}
我ADDUSER()函數如下:
public function addUser(){
$user = new Users();
if(isset($_POST['regsignup']) && $_POST['regsignup'] == 'Register'){
$user->setUserEmail($_POST['regemail']);
$user->setUserPassword($_POST['regpass']);
$user->setUserFname($_POST['regfname']);
$user->setUserLname($_POST['reglname']);
$user->setUserPhoneno($_POST['regcell']);
}
$dbconn = new DbConn();
$db = $dbconn->getDB();
$user_email = $user->getUserEmail();
$user_pass = $user->getUserPassword();
$user_fname = $user->getUserFname();
$user_lname = $user->getUserLname();
$user_cell = $user->getUserPhoneno();
$sql = "insert into users (user_password, user_fname, user_lname, user_phoneno, user_email) values('$user_pass','$user_fname','$user_lname','$user_cell','$user_email')";
$r = $db->exec($sql);
return $r;
}
你會得到任何錯誤? –
如果你收到一些錯誤,如「Headers already sent ......」,然後在腳本的第一行寫上_ob_start()_ –
我沒有收到任何錯誤,只是它仍然是一樣的頁面@SureshKamrushi – Tanu