I made 3 files:
submitrecipe.php
searchrecipe.php
reciperesult.php
I don't have any problem submitting imformation with "submitrecipe" to mysql database. I managed to make "searchrecipe.php" too (I think so
Here is "submitrecipe.php" (I don't have problem with this form)
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="submitrecipe.php">
<label><strong>SUBMIT YOUR RECIPE</strong><br />
<br />
Name<br />
<input type="text" name="yourname" id="yourname" />
</label>
<p>Country<br />
<label>
<select name="yourcountry" id="yourcountry">
<option>USA</option>
<option>CANADA</option>
<option>ENGLAND</option>
</select>
</label>
</p>
<p>Type of Food <br />
<label>
<select name="typeoffood" id="typeoffood">
<option>DESERT</option>
<option>ENTREE</option>
<option>SPICY</option>
</select>
</label>
</p>
<p>Your recipe<br />
<label>
<textarea name="yourrecipe" id="yourrecipe" cols="45" rows="5"></textarea>
</label>
</p>
<p>
<label>
<input type="submit" name="Submit" id="Submit" value="Submit" />
</label></p>
</form>
<?php
$dbcnx = @mysql_connect('localhost', 'root', '');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' . 'database server at this time.</p>');
}
if (!@mysql_select_db('recipetime')) {
exit('<p>Unable to locate the recipe ' . 'database at this time.</p>');
}
if (isset($_POST['yourrecipe'])):
// A new recipe has been entered
// using the form.
$yourname = $_POST['yourname'];
$yourcountry = $_POST['yourcountry'];
$typeoffood = $_POST['typeoffood'];
$yourrecipe = $_POST['yourrecipe'];
$sql = "INSERT INTO recipeform SET
name='$yourname',
country='$yourcountry',
typeoffood = '$typeoffood',
yourrecipe='$yourrecipe'";
if (@mysql_query($sql)) {
echo '<p>New recipe added</p>';
} else {
exit('<p>Error adding new recipe: ' . mysql_error() . '</p>');
}
?>
<?php endif; ?>
</body>
</html>
Here is "searchrecipe.php" (I don't have problem with this one either. As far as I know)
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php $dbcnx = @mysql_connect('localhost', 'root', '');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}
if (!@mysql_select_db('recipetime')) {
exit('<p>Unable to locate the recipe ' .
'database at this time.</p>');
}
?>
<form id="form1" name="form1" method="post" action="reciperesults.php">
<label><strong>SEARCH RECIPE</strong><br />
<br />
</label>
<p>Country<br />
<label>
<select name="country" id="country">
<option>USA</option>
<option>CANADA</option>
<option>ENGLAND</option>
</select>
</label>
</p>
<p>Type of Food <br />
<label>
<select name="typeoffood" id="typeoffood">
<option>DESERT</option>
<option>ENTREE</option>
<option>SPICY</option>
</select>
</label>
</p>
<p>
<label>
<input type="submit" name="Search" id="Search" value="Search" />
</label>
</p>
</form>
</body>
</html>
Now I don't know how to make this file "reciperesult.php"
Can anybody help. Thanks a lot.