Hey,
I'm trying to get info from a from and do a query with that info
Code:
<html>
<head>
<title>Test php finder page</title>
</head>
<body>
<form action="test.php" method=POST>
<input type=text name=name>
<input type=submit name=foo value="GO GO SEARCH MONKEY!">
</form>
</body>
</html>
That's my form that gets the data
Now here's the page that's supposed to display the results:
<?php
/ Connecting, selecting database /
$link = mysql_connect("localhost", "root", "omitted")
or die("Could not connect : " . mysql_error());
echo "Connected successfully";
mysql_select_db("hopkinton") or die("Could not select database");
/ Performing SQL query /
$query = "SELECT * FROM address WHERE name = $_POST['name']";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
/ Printing results in HTML /
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
/ Free resultset /
mysql_free_result($result);
/ Closing connection /
mysql_close($link);
?>
Can anyone tell me why this don't work?
Thanks