₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,152 members, 8,420,574 topics. Date: Friday, 05 June 2026 at 03:04 AM

Toggle theme

Please Need A Help HEADER ERROR In Php - Webmasters - Nairaland

Nairaland ForumScience/TechnologyWebmastersPlease Need A Help HEADER ERROR In Php (391 Views)

1 Reply (Go Down)

Please Need A Help HEADER ERROR In Php by Cordova(op):
Please, can somebody help fix this php error. I was trying to redirect to a new page after form submission but its leaving the page. I tried to print out the session id which worked. But I don't know what is wrong

function activate(){
if(isset($_POST['activate'])){
if(empty($_POST['usr']) || empty($_POST['password']) || empty($_POST['code'])){
echo 'Please enter both the username, password and the activation code.';
}else{
$uname = addslashes(htmlentities($_POST['usr']));
$code = addslashes(htmlentities($_POST['code']));
$pword = $_POST['password'];
$pword_hash = md5($pword);
$query = "SELECT uId FROM m_account WHERE username = '$uname' AND pwrd = '$pword_hash' AND activation_code = '$code' ";
$result = mysql_query($query);
if(mysql_num_rows($result)== "" ){
echo 'Invalid Data Combination.';
}else{
$user_id = mysql_result($result, 0, 'uId' ) ;
$_SESSION['user_id']=$user_id;
if($_SESSION['user_id']){
header("Location: myDashboard.php" ) ;
}else{
echo 'Is not be successful';
}

}
}
}
}

Please, any help will be appreciated. Especially for the redirect.
Re: Please Need A Help HEADER ERROR In Php by Nobody: 4:28pm On Jul 29, 2016
Type in ({fxck}}}}=php, it might work undecided angry
Re: Please Need A Help HEADER ERROR In Php by hollyfat(m): 6:41pm On Jul 29, 2016
Cordova:
Please, can somebody help fix this php error. I was trying to redirect to a new page after form submission but its leaving the page. I tried to print out the session id which worked. But I don't know what is wrong

function activate(){
if(isset($_POST['activate'])){
if(empty($_POST['usr']) || empty($_POST['password']) || empty($_POST['code'])){
echo 'Please enter both the username, password and the activation code.';
}else{
$uname = addslashes(htmlentities($_POST['usr']));
$code = addslashes(htmlentities($_POST['code']));
$pword = $_POST['password'];
$pword_hash = md5($pword);
$query = "SELECT uId FROM m_account WHERE username = '$uname' AND pwrd = '$pword_hash' AND activation_code = '$code' ";
$result = mysql_query($query);
if(mysql_num_rows($result)== "" ){
echo 'Invalid Data Combination.';
}else{
$user_id = mysql_result($result, 0, 'uId' ) ;
$_SESSION['user_id']=$user_id;
if($_SESSION['user_id']){
header("Location: myDashboard.php" ) ;
}else{
echo 'Is not be successful';
}

}
}
}
}

Please, any help will be appreciated. Especially for the redirect.
If you are using php5 and above, redirection won't work if you have echo or print some data before the
header("location:location.php"wink;
code
Re: Please Need A Help HEADER ERROR In Php by ps3o(m): 9:22pm On Jul 29, 2016
Cordova:
Please, can somebody help fix this php error. I was trying to redirect to a new page after form submission but its leaving the page. I tried to print out the session id which worked. But I don't know what is wrong

function activate(){
if(isset($_POST['activate'])){
if(empty($_POST['usr']) || empty($_POST['password']) || empty($_POST['code'])){
echo 'Please enter both the username, password and the activation code.';
}else{
$uname = addslashes(htmlentities($_POST['usr']));
$code = addslashes(htmlentities($_POST['code']));
$pword = $_POST['password'];
$pword_hash = md5($pword);
$query = "SELECT uId FROM m_account WHERE username = '$uname' AND pwrd = '$pword_hash' AND activation_code = '$code' ";
$result = mysql_query($query);
if(mysql_num_rows($result)== "" ){
echo 'Invalid Data Combination.';
}else{
$user_id = mysql_result($result, 0, 'uId' ) ;
$_SESSION['user_id']=$user_id;
if($_SESSION['user_id']){
header("Location: myDashboard.php" ) ;
}else{
echo 'Is not be successful';
}

}
}
}
}

Please, any help will be appreciated. Especially for the redirect.
use if (isset($_SESSION['user_id'])){

header(location: file.PHP);
exit();


}

make sure U call that session variable on the file which is redirected to without leaving any blank space.

<?php if(! isset($_SESSION['user_id'])){
redirect to login page
}


?>
1 Reply

Error In FoxproHow To Make Static Header On Coded WebsiteHow To Set Up Custom Robot Txt And Custom Robots Header Tags On Blogger234

Comparison--> Wordpress VS BloggerWhich Blogging Platform Are You Currently Using; Or Wordpress?Why SEO Keeps Changing The Way It Works