Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,511 members, 7,819,842 topics. Date: Tuesday, 07 May 2024 at 02:32 AM

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

Nairaland Forum / Science/Technology / Webmasters / Please Need A Help HEADER ERROR In Php (328 Views)

Error In Foxpro / How To Make Static Header On Coded Website / How To Set Up Custom Robot Txt And Custom Robots Header Tags On Blogger (2) (3) (4)

(1) (Reply) (Go Down)

Please Need A Help HEADER ERROR In Php by Cordova: 4:14pm On Jul 29, 2016
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)

Best Host For Sms Site / Get Yourself A .com Domain For #3000 Beta Host Web Hosting / The Latest Social Network

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 19
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.