Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4017566
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:52:36+00:00 2026-05-20T09:52:36+00:00

I tried transferring a working login system from one domain to another. It works

  • 0

I tried transferring a working login system from one domain to another. It works perfectly on domain A, but starts giving errors:

Warning: Cannot modify header
information – headers already sent by
(output started at
/home/hootlute/public_html/personal/example/files/admin/config.php:9)
in
/home/hootlute/public_html/personal/example/files/admin/admin_process.php
on line 34

Warning: mysql_free_result(): supplied
argument is not a valid MySQL result
resource in
/home/hootlute/public_html/personal/example/files/admin/admin_process.php
on line 48

Below is my code from admin_process

<?php
session_start(); 
if ($_POST['adminID']=="") {
    $_SESSION['error']="Please log in with an admin account.";
    header('Location: http://login.example.com/login/admin');
}

include 'config.php';
include 'functions.php';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);

$sql = "SELECT * FROM admin WHERE username='" .$_POST["adminID"]. "' AND password='" .$_POST["password"]. "'";
$result = mysql_query($sql);

if (!$result) {
    die('Invalid query: ' . mysql_error());
}

$num_rows = mysql_num_rows($result);


// CHECKS FOR EXISTING ACCOUNT
if ($num_rows === 0) {
    $_SESSION['error']="Unable to log in. Admin account not found";
    printf("<script>location.href='http://login.example.com.com/login/'</script>");

}
else {
    $admin_rows = mysql_fetch_assoc($result);
    $cookie_info = $admin_rows['admin_id']."$".$admin_rows['name'];
    $expire = time() + 9800;
    setcookie("FS_admin_id",$cookie_info,$expire);
    $sql = "UPDATE admin set login_time = UTC_TIMESTAMP()  WHERE username='" .$_POST["adminID"]. "' AND password='" .$_POST["password"]. "'";
    $logresult = mysql_query($sql);

    if (!$logresult) {
        die('Invalid query: ' . mysql_error());
    }


    /* printf("<script>location.href='admin_home.php'</script>"); */

}

mysql_free_result($result);
mysql_free_result($logresult);
mysql_close($conn);



?>

Line 34 = setcookie(“FS_admin_id”,$cookie_info,$expire);

What is wrong with the code? Is it because of the difference in PHP version ?
I also get the same type of errors when I declare session_start() in the middle of my codes… despite not having any data printed.

I’ve been searching for setcookie() problems but the results were all related to the usage of setcookie().

Any reply will be much appreciated 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:52:36+00:00Added an answer on May 20, 2026 at 9:52 am

    Let me answer here as well 😀

    Check line 9 in config.php 🙂 I bet you have a trailing whitespace there.

    EDIT:
    To avoid this in future, just remove ALL final ?> lines from your PHP scripts. PHP can live without them 🙂 And also heed Lekensteyn’s advice re SQL Injection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Tried to map it from Preferences -> Settings -> Keyboard, but the key combo
Tried examples from 'php.net' but don't understand what's the problem. Any suggestions? <?php $_SESSION['test']
Have anyone tried to transfer file from Server to Client? or Transferring XML from
I use something like below to pass information from one unbound form to another
Tried a bunch of things but I can't get it to work consistently amid
tried to find the answer by googling and in MSDN but with no luck.
Tried to install some program, it gives above message requiring 1.1.4322. BUT as the
tried to research on that but sometimes I seem to lack some googling skills...
I am executing the following query in a stored procedure, transferring one year's transactions
I'm working with the C# membership provider and transferring it to LINQ along the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.