Page 1 of 1

Question about 'isset'

Posted: Thu Jun 09, 2005 10:39 pm
by Wldrumstcs
I am working on a little project and understand that my problem could potentially be solved using 'isset'. However, I do not know how to use it properly, so I would greatly appreciate if someone could tell me what to write instead.

Okay, I am getting an error saying 'undefined index on line 7'. How can I rewrite this to work? I appreciate the help!

Code: Select all

<? IF($_SERVER['QUERY_STRING'] != "" AND $_SERVER['QUERY_STRING'] != "view=advanced") {
$body = "
<h3>There was an error in loading this page because a link was not clicked to access it.</h3>
<br>
<h5><a href='search.php'>Click here to access the search page</a>.</h5>
";
}ELSEIF($_GET["view"] == "" OR $_SERVER['QUERY_STRING'] = ""){
$advancedsearch_link = "
<p><a href='search.php?view=advanced'>Advanced Search</a></p>
";
$body = "
<form method='GET' action='results.php'>
	<input type='text' tabindex='1' name='query' size='25' maxlength='50'  onfocus=\"if(this.value == this.defaultValue){this.value = ''}\" value='Enter keywords here' />
	<input type='submit' value='Search' name='search_submit' tabindex='2'>
		$advancedsearch_link
		</form>
";
}

Posted: Thu Jun 09, 2005 10:47 pm
by harrison
check if a variable was passed to the script by this.

Code: Select all

if(isset($_GET['name'])){
$view = $_GET['name'];
}else{
echo "warning: name was not passed";
}
// or ...
$view = (isset($_GET['name'])?$_GET['name']:'');
Learn more of isset at google search.

Posted: Thu Jun 09, 2005 11:56 pm
by anjanesh

Posted: Fri Jun 10, 2005 10:56 am
by Wldrumstcs
Thank you very much!