A simple IF condition.
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

A simple IF condition.

From: Alec <ajtdds@aol.com>
Date: Fri Sep 02 2005 - 14:46:29 CEST

I have a simple IF condition to check whether an entered town name for
a search actually exists in the database.

The form search produces $townsearch

The check should return "Cannot Find The Town" if $townsearch does not
correspond to a recognised townname in the database.

The database is correct, and the SQL query OK.

So why can I type anything in and it accepts it??

(Day 4 of learning PHP)

Alec

<?php $townsearch = $_GET['town']; ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<input type="text" name="town" size="20" value="<?php echo $townsearch;
?>" />&nbsp;
<input type="submit" value="GO" />

<?php
$check = @mysql_query ("SELECT townname FROM site01_towns WHERE
townname='$townsearch'");
if (!$check)
{
echo '<p>Cannot Find The Town</p>';
exit();

}

?>
Received on Tue Oct 18 02:17:41 2005