Re: PHP Newbee Question

From: Date: Tue, 02 Jul 2002 14:15:32 +0000
Subject: Re: PHP Newbee Question
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-20263@lists.php.net to get a copy of this message
Variable names are case-sensitive in PHP - try $HTTP_POST_VARS["first"] - or, for new versions of PHP, $_POST["first"]. In another train of thoughts, please use the proper e-mail address - I'm sure I'm not the only one using filters to automatically move mail to folders and your although probably valid according to the RFC, the way you formatted the php list e-mail address doesn't match the filter names... Thanks! Bogdan Jeffrey Norsworthy wrote:
Hello All, I am new to PHP, and I am trying to design what I thought would be a fairly simple form, that queries a MYSQL database for two fields, (first, and last name). It should then return the entire results of the entry in the table. This part is actually 5 fields. If I run the script with static entries for "first", and "last", the process work flawlessly (as it should). If I try using variables for the search values, I do not receive any results. I have tried changing the form method from post, to get, and the problem continues. Any help would be greatly appreciated. Thank you. The first grouping is the html form, the second set is the php form that actually performs the search. Also the username, and password are populated in the actual script, I just took them out for the email. Thanks again. <html> <head><title>Contact lookup form</title></head> <body> <form action="test.php" method="post"> First Name: <input type="text" name="first"><br> Last Name: <input type="text" name="last"><br> <input type="submit" value="lookup"> </form> </body> </html> <?php define ('mysql_host', 'localhost'); define ('mysql_user', ''); define ('mysql_pass', ''); define ('mysql_db', 'chs'); if (! mysql_connect(mysql_host, mysql_user, mysql_pass) ) { die('Failed to connect to host " ' . mysql_host . ' " . '); } else { echo '' . mysql_host . '<br>'; } mysql_select_db(mysql_db); if ($http_get_vars['first'] && $http_get_vars['last']) { echo $http_get_vars['first'] . ' ' . $http_get_vars['last'] . '<br>'; } $result=mysql_query("select * from chs where first='$first' or last='$last'"); echo "<h2 align='center'>Results</h2>"; while ($row = mysql_fetch_array($result)) {
       echo "<b>{$row['first']}&nbsp{$row['last']}&nbsp&nbsp&nbsp{$row['branch']}&nbsp&nbsp&nbsp{$row['extension']}&nbsp&nbsp
&nbsp{$row['voice_mail']}&nbsp&nbsp&nbsp{$row['position']}</b> <br>"; } ?> Jeffrey Norsworthy MCP, CCNA Network Administrator Community Health Services norswj@chsmaine.org
Mail scanat cu RAV Antivirus!

« previous php.db (#20263) next »