/    Sign up×
Community /Pin to ProfileBookmark

Why $_GET Value Not Grabbed Or Echoed ?

My lovely jovely php Folkies!

Look at this script. It shows you browsing history of a username (user of a web proxy).
Url format:
browsing_history.php?browsing_history_user=USERNAME

If the visitor goes to a wrong format url such as these then he should get an error.
This url does not contain the $_GET part.
browsing_history_v1.php?

This one does not contain the Username in the $_GET part.
browsing_history_v1.php?browsing_history_user=

I have a User “admin123”. Hence, this url should pull the browsing history of: admin123.
browsing_history_v1.php?browsing_history_user=admin123
But, I still get the error:
“In the url, type the Username of the visitor who’s browsing history you want to search! <br>
Type after the part:
“?browsing_history_user=”.
Then, press: ENTER.”.

Why is the ELSE getting triggered instead of the THEN when the url does contain the $_GET value ?

Full script.
Concentrate on the 3rd php tags (<?php & ?>).

[code]
<?php
//Required PHP Files.
include ‘configurations_site.php’; //Required on all webpages of the site. Must include here too. Else, conn.php data would not be found. conn.php residing in site_configurations.php.
include ‘header_site.php’; //Required on all webpages of the site.
include ‘header_account.php’; //Required on all webpages of the account.
include ‘sessions.php’; //Required on all webpages of the site.
?>

<?php
//Check if User is already logged-in or not. Get the login_check() FUNCTION to check.
if (login_check() === FALSE)
{
//Redirect User to Log-in Page immediately.
//header(“refresh:0; url=home.php”);
header(“location:login.php”);
exit();
}
?>

<?php
//Grab Username of who’s Browsing History needs to be searched.
if (isset($_GET[‘browsing_history_user=’]) && !empty($_GET[‘browsing_history_user=’]))
{
$browsing_history_user = $_GET[“browsing_history_user=”];
echo “$browsing_history_user”; //WHY THE VALUE OF THIS VARIABLE NOT GETTING ECHOED WHEN VISITING URL: browsing_history_v1.php?browsing_history_user=admin123
}
else
{
//WHY FOLLOWING GETTING ECHOED AFTER VISITING: browsing_history_v1.php?browsing_history_user=admin123
die(“In the url, type the Username of the visitor who’s browsing history you want to search! <br>
Type after the part:<br>
“?browsing_history_user=”. <br>
<br>
Then, press: ENTER. <br>”);
}
?>

<?php
$user = $_SESSION[“user”];
?>

<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional/EN”>
<html>
<head>
<meta content=”text/html; charset=ISO-8859-1″ http-equiv=” content-type”>
<title><?php echo “$site_name User $browsing_history_user Browsing History in $server_time time.”;?></title>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
</head>
<body>
<br>
<p align=”center”><span style=”font-weight:bold;”><?php echo “$site_name User $browsing_history_user Browsing History in $server_time time.”;?></span></align>
<br>
<br>
<?php
if (!$conn)
{
$error = mysqli_connect_error();
$errno = mysqli_connect_errno();
print “$errno: $errorn”;
exit();
}
else
{
$query = “SELECT * FROM browsing_histories WHERE username = “$browsing_history_user””;
$result = mysqli_query($conn,$query);
$rows_num = mysqli_num_rows($result);

//Total Number of Pages records are spread-over.
$page_count = 10;
$page_size = ceil($rows_num / $page_count);
//Get the Page Number. Default is 1 (First Page).
$page_number = $_GET[“page_number”];
if ($page_number == “”) $page_number = 1;
$offset = ($page_number -1) * $page_size;

$query .= ” limit {$offset},{$page_size}”;
$result = mysqli_query($conn,$query);
?>
<table width=”1500″ border=”0″ cellpadding=”5″ cellspacing=”2″ bgcolor=”#666666″>
<?php
if($rows_num)
{
printf(“<b> %d Result Found …</b>n”,$rows_num); ?><br>
<br>
<tr name=”headings”>
<td bgcolor=”#FFFFFF” name=”column-heading_submission-number”>Submission Number</td>
<td bgcolor=”#FFFFFF” name=”column-heading_logging-server-date-and-time”>Date & Time in <?php echo “$server_time”;?></td>
<td bgcolor=”#FFFFFF” name=”column-heading_browsed-page”>Browsed Page</td>
<td bgcolor=”#FFFFFF” name=”column-heading_referral-page”>Referral Page</td>
<td bgcolor=”#FFFFFF” name=”column-heading_username”>Username</td>
<td bgcolor=”#FFFFFF” name=”column-heading_gender”>Gender</td>
<td bgcolor=”#FFFFFF” name=”column-heading_age-range”>Age Range</td>
<td bgcolor=”#FFFFFF” name=”column-heading_religion”>Religion</td>
<td bgcolor=”#FFFFFF” name=”column-heading_education”>Education</td>
<td bgcolor=”#FFFFFF” name=”column-heading_profession”>Profession</td>
<td bgcolor=”#FFFFFF” name=”column-heading_marital-status”>Marital Status</td>
<td bgcolor=”#FFFFFF” name=”column-heading_working-status”>Working Status</td>
<td bgcolor=”#FFFFFF” name=”column-heading_home-town”>Home Town</td>
<td bgcolor=”#FFFFFF” name=”column-heading_home-city”>Home City</td>
<td bgcolor=”#FFFFFF” name=”column-heading_home-borough”>Home Borough</td>
<td bgcolor=”#FFFFFF” name=”column-heading_home-county”>Home County</td>
<td bgcolor=”#FFFFFF” name=”column-heading_home-region”>Home Region</td>
<td bgcolor=”#FFFFFF” name=”column-heading_home-state”>Home State</td>
<td bgcolor=”#FFFFFF” name=”column-heading_home-country”>Home Country</td>
</tr>
<?php while($row = mysqli_fetch_array($result))
{
?>
<tr name=”user-details”>
<td bgcolor=”#FFFFFF” name=”submission-number”><?php echo $row[‘id’]; ?></td>
<td bgcolor=”#FFFFFF” name=”logging-server-date-&-time”><?php echo $row[‘date_and_time’]; ?></td>
<td bgcolor=”#FFFFFF” name=”browsed-page”><?php echo $row[‘browsed_page’]; ?></td>
<td bgcolor=”#FFFFFF” name=”referral-page”><?php echo $row[‘referral_page’]; ?></td>
<td bgcolor=”#FFFFFF” name=”username”><?php echo $row[‘username’]; ?></td>
<td bgcolor=”#FFFFFF” name=”gender”><?php echo $row[‘gender’]; ?></td>
<td bgcolor=”#FFFFFF” name=”age-range”><?php echo $row[‘age_range’]; ?></td>
<td bgcolor=”#FFFFFF” name=”recligion”><?php echo $row[‘religion’]; ?></td>
<td bgcolor=”#FFFFFF” name=”education”><?php echo $row[‘education’]; ?></td>
<td bgcolor=”#FFFFFF” name=”profession”><?php echo $row[‘profession’]; ?></td>
<td bgcolor=”#FFFFFF” name=”marital-status”><?php echo $row[‘marital_status’]; ?></td>
<td bgcolor=”#FFFFFF” name=”working-status”><?php echo $row[‘working_status’]; ?></td>
<td bgcolor=”#FFFFFF” name=”home-town”><?php echo $row[‘home_town’]; ?></td>
<td bgcolor=”#FFFFFF” name=”home-borough”><?php echo $row[‘home_borough’]; ?></td>
<td bgcolor=”#FFFFFF” name=”home-city”><?php echo $row[‘home_city’]; ?></td>
<td bgcolor=”#FFFFFF” name=”home-county”><?php echo $row[‘home_county’]; ?></td>
<td bgcolor=”#FFFFFF” name=”home-region”><?php echo $row[‘home_region’]; ?></td>
<td bgcolor=”#FFFFFF” name=”home-state”><?php echo $row[‘home_state’]; ?></td>
<td bgcolor=”#FFFFFF” name=”home-country”><?php echo $row[‘home_country’]; ?></td>
</tr>
<?php
}
?>
<tr name=”pagination”>
<td colspan=”19″ bgcolor=”#FFFFFF”> Result Pages:
<?php
if($rows_num <= $page_size)
{
echo “Page 1”;
}
else
{
for($i=1;$i<=$page_count;$i++)
echo “<a href=”{$_SERVER[‘PHP_SELF’]}?page_number={$i}”>{$i}</a> “;
}
?>
</td>
</tr>
<?php
}
else
{
?>
<tr>
<td bgcolor=”#FFFFFF”>No record found! Try another time.</td>
</tr>
<?php
}
?>
</table>
<br>
<br>
<p align=”center”><span style=”font-weight:bold;”><?php echo “$site_name User $browsing_history_user Browsing History in $server_time time.”;?></span></align>
<br>
<br>
</div>
<br>
</body>
</html>
<?php
}
?>
[/code]

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmNov 23.2018 — All this f.... code and the problem is simply that you have included an '=' sign in your logic. The GET arg is simply the name, not the =.
Copy linkTweet thisAlerts:
@rootNov 24.2018 — > @site-developer#1598199 $_GET['browsing_history_user=']

Is another example of how you are failing to take on board how you address things, $_GET is like $_POST that is like $_SESSION or $_SERVER or $myAssociativeArray

if something is called browsing_history_user then you refer to it as browsing_history_user and not browsing_history_user= as that is something altogether different.

Its the same as expecting $MYVARIABLE = 20 to use $myvariable and expect it to spit out 20 as the answer... Not happening.

A lot of the issues you are posting, it is clear that you are not employing the most rudimentary trouble shooting.

If you are going to continue to receive help from the site, I suggest you start learning and troubleshooting, if you don't know how to troubleshoot an issue, then ask.
Copy linkTweet thisAlerts:
@ginerjmNov 24.2018 — Root - here here!!

It's about time that someone spoke up and tried to tell this phantom user who pops up all over using different ids that it is quite obvious that programming is NOT HIS THING! The people on several forums spend way too much time and energy trying to pound home the SIMPLEST concepts repeatedly and get no results for their efforts. I realize that he/she may have some difficulties in learning but after this much time has transpired perhaps this user needs to apply his mind to another hobby or skill.

And about all I/we are going to get from this post is more gibberish that is meaningless to us.
Copy linkTweet thisAlerts:
@NogDogNov 24.2018 — Stick this at the beginning of each PHP script:
[code=php]
<?php
ini_set('display_errors', true);
error_reporting(E_ALL);
[/code]

Then when you mis-typed the array key like that, it will throw a warning to that effect, specifying the file and line number, and you'd already know where the problem is.
Copy linkTweet thisAlerts:
@site-developerauthorNov 25.2018 — @ginerjm#1598200

Lol!

I really like YOU!

LOL!
Copy linkTweet thisAlerts:
@site-developerauthorNov 25.2018 — @root#1598212

Oops!

I was working till sunset and had sleep in my eyes!

The "=" was a typo! ?

Working now perfect!

Thanks!
Copy linkTweet thisAlerts:
@site-developerauthorNov 25.2018 — @NogDog#1598223

Got no error here. Not supposed to.

In an included file error reporting is on.

<i>
</i>&lt;?php

//ERROR REPORTING CODES.
declare(strict_types=1);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

?&gt;
×

Success!

Help @site-developer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...