Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if there is a parameter in the header

Status
Not open for further replies.
In this instance you could check the array $_GET to see if anything is in it
 
Is there any chance you can post me an example? as i am still a little confused?

kindest regards.
 
How much PHP do you know ??

the example you give is supplying what is called a querystring. When PHP does its thing in conjunction with the webserver it will put all values into the array $_GET.
in your script test.php put the line print_r($GET) at the top and you will see what i mean
 
Im a newby to PHP, bit confused.

these are the error messages i get..

Notice: Undefined index: id in E:\php-develop\resellers\test.php on line 8

Warning: Cannot modify header information - headers already sent by (output started at E:\php-develop\resellers\test.php:8) in E:\php-develop\resellers\test.php on line 12

This is my code...


<?
//print_r($_GET);
include 'db.php';

// Convert to simple variables

//$id = $_REQUEST['id'];
$id = $_GET['id'];

if (!$id) {

header("Status: 404 Not Found");
// header("HTTP/1.1 401 Unauthorized");

exit();
}



// check if the id info validates the db
$sql = mysql_query("SELECT * FROM resellers WHERE code='$id'");
$login_check = mysql_num_rows($sql);

if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
// Register some session variables!
session_register('company_name');
$_SESSION['company_name'] = $company_name;
session_register('notification_email');
$_SESSION['notification_email'] = $notification_email;

//header("Location: login_success.php");
include 'test.php';
}
} else {
header("Status: 404 Not Found");
// header("HTTP/1.1 401 Unauthorized");
}
?>

The more difficult stuff seams to work ok!

 
ok, we've all been there !

look at this code fragment

Code:
<?php

print_r($_GET);

if (array_key_exists("uid",$_GET))
   echo " got it - uid is "  . $_GET["uid"];
else
   echo "no such key";
?>

Can you see how it works ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top