Hi! I'm working on a form that submits a recipe that enters data into a db. The form has a name (of the cook) field, a title of the recipe field, an ingredient field, and a directions/additional info field. The ingredient field, has multiple items in the same field, so each item needs to have at least one <br> seperating the items. How can this be done? Here's the php code that inserts the form data into the db:
<?php
//Get data from form:
if (isset ($_POST['Submit'])) {
//Connect to DB:
if ($dbc = @mysql_connect ('localhost', 'username', 'pword'))
{
//Select to DB:
if (!@mysql_select_db ('hughfayphillarrydaveterry_com_-_zcms'))
{
die ('Could not select the database because:' . mysql_error() . '<br>');
}
} else {
die ('Could not connect to MySQL because:' . mysql_error() . '<br>');
}
//Define $sql:<br>
$email = $_POST["email"];
$name = $_POST["name"];
$title = $_POST["title"];
$img = $_POST["ing"];
$dir = $_POST["dir"];
$sql = "INSERT INTO recipe (name,title,ingredients,directions,email)
VALUES ('$name','$title', '$ing','$dir','$email')";
//Add the entry:
if (@mysql_query ($sql)) {
} else {
print "Could not add the entry because:" . mysql_error() . "Sorry! <br>";
}
//Define $read:
$read = "SELECT * FROM `recipe`";
//Read the entries:
if (@mysql_query ($read)) {
} else {
print "Could not read because:" . mysql_error() . " Sorry! <br>";
}
print "<span class='art_Title'>Your recipe has been added!</span><br><span class='art_body'>Thank you $name, for entering the $title recipe. We really appreciate your contribution! It has now been added to the <a href=zms.php?name=rec>family cookbook</a>!</span>";
//Close connection:
mysql_close();
//If else, print:
} else {
print "<span class=art_Title>There was a fatal error!</span><br><span class=art_body>$name, we're sorry to report that there was a fatal error while trying to add the $title recipe. We would really appreciate it if you would contact <a href=mailto:zakfr@bellsouth.net>Zak Robertson</a> to report the error. If you would like, you can try to <a href=add_recipe.php>enter the recipe again</a>.";
}
?>
So, how can this be done?
I really appreciate your help! Thanks!
Zak