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

  • Home
  • SEARCH
  • 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 8297061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:15:41+00:00 2026-06-08T15:15:41+00:00

I am looking for some kind of bug in my code which is causing

  • 0

I am looking for some kind of bug in my code which is causing this PHP page to not redirect. I’m looking to see if someone might know the cause of this problem (it may have something to do with the cookies).

inc_vars.php:

<?php
//some of the variables have been omitted.
$pid = 'gbb';
$dbtable ='';
$dbname = '';
$dbuser = '';
$dbpass = '';

$connect = mysql_connect('localhost', $dbuser, $dbpass);

if(!$connect){
    header('Location: omitted');
    die();
}

mysql_select_db ($dbname, $connect);

$webroot = 'omitted';

$share_page = $webroot . '/share-the-training';

$gift = $webroot . '/free-video?setuser=1199';

$bonus_content = $webroot . '/awesome-bonus';

$share_php = $webroot . '/share.php';

?>

refresh_id.php:

<?php

include_once('inc_vars.php');

$results = mysql_query("SELECT id FROM " . $dbtable . " WHERE email='" . $_GET['email'] . "'");


if(!$results || mysql_num_rows($results)==0){
    header('Location: ' . $share_page . '?errorcode=1');
    die();
}

$res_arr = mysql_fetch_assoc ($results);

setcookie($pid . "_viral", (string)$res_arr['id'], time() + 3600 * 365);

move_on();

function move_on(){
    header ('Location: ' . $share_php);
    die();
}

?>

When the person visits refresh_id.php?email=their_email they should redirect to the $share_php page. This is not working.

However, if this scenario happens: refresh_id.php?email=an-email-that-is-not-in-database then the script redirects to $share_page absolutely fine.

I have tried this with and without the gbb_viral cookie in place. I’m not sure why this isn’t working. All pages are live and on the internet right now in case you want to look for yourself.

omitted

An email that exists in the database is as follows: acctrafficcop@gmail.com (for those that want to test this)

UPDATE

Stupid mistake with scopes. I simply added global $share_php in the move_on() function and everything is working fine now. Thank you everyone for the heads up on SQL injection, I am switching over to prepared statements right now.

  • 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-06-08T15:15:45+00:00Added an answer on June 8, 2026 at 3:15 pm

    In your move_on function, the variable $share_php does not exist because of variable scope. Therefore your redirect looks like this: Location:. There is no URL in the Location header.

    You can pass the variable into the function, or use the global keyword to make it available. Try this:

    move_on('/redirect_url');
    
    function move_on($url){
        header ('Location: ' . $url);
        die();
    }
    

    In fact, in refresh_id.php I don’t see a variable called $share_php anywhere, so you are redirecting to an empty URL.

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

Sidebar

Related Questions

I am looking out for some kind of short code where i should not
I guess I am looking for some kind of intro and see if anybody
Looking at some assembly code for x86_64 on my Mac, I see the following
I am looking for some kind of online subscription payment system which is kind
I'm looking for some kind addon for browser (firefox, opera, ie, chrome, etc...), which
I am looking at some Web2py code. The variable tokens is some kind of
May be my title is not clear. I am looking for some kind of
While looking through some example C code, I came across this: y -= m
I am looking at some code from one of our customers and found this
Before we develop our custom solution, I'm looking for some kind of library, which

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.