Undefined Variables

A

Anonymous

Guest
I have been following Sam's Php + Mysql web developement book.

Having written out the script the way the book has them:

trim($searchterm);
if(!searchtype || !searchterm)

When I ran the script I got the error undefined variables.

Having sifted through various sites and tutorials I found one that showed me the following I have adapted to suit:

trim($_POST['searchterm']);
if(empty($_POST['searchtype']) || empty($_POST['searchterm']));

I now recieve no error message so I believe it is being parsed. However, that is as far as the script runs, receiveing the message "You have not entered details. Please return to form."

I have checked the form and can see no problem there all layed out as stated in the book (not that this is much comfort seeing as most scripts dont work or are non globals off compliant).

Has anyone else had these particular problems and can anybody tell me why is the variables not being passed from the form.

Thank you
 
try echoing the variables prior to any if clauses (which shouldn't have ; after them)

echo $_POST['searchterm'];
if(isset($_POST['searchterm']))
{
// stuff
 
as you read in this post http://www.php-forum.com/p/viewtopic.php?t=1483 your book should be burned.

please post more code.
 
Having read all your responses I have found useful and got through the rest of the script ok.

Even the guy who thinks he's god or maybe doesnt I guess you were pushing me towards the include_once function thanks.

At the same time as buying Sams php web development I bought their Developer Cookbook is this a waste of money too or could I possibly find that more useful

Thanks
 
Back
Top