lmcgr44 Posted October 26, 2010 Share Posted October 26, 2010 hello i am making a online cook for people to register and make and online cookbook on there account i want them to be able to add recipes and be able to see them on there file, i know how it would connect to the database and how to send the information but what tables would i use and what fields? this is my basic site now www.lachlanmcgrath.net, if you can help please reply here or even e-mail me at lmcgr44@me.com thank-you for your help Quote Link to comment https://forums.phpfreaks.com/topic/216871-mysql-and-php-help/ Share on other sites More sharing options...
litebearer Posted October 26, 2010 Share Posted October 26, 2010 A good starting point would be to 'examine' some free cookbook scripts to see how others have setup/designed their creations... http://www.google.com/#hl=en&expIds=17259,18168,26637,26718,26992,27182&sugexp=ldymls&xhr=t&q=php+free+cookbook+scripts&cp=25&pf=p&sclient=psy&aq=f&aqi=&aql=&oq=php+free+cookbook+scripts&gs_rfai=&pbx=1&fp=956ab502b015b9a1 Quote Link to comment https://forums.phpfreaks.com/topic/216871-mysql-and-php-help/#findComment-1126644 Share on other sites More sharing options...
drisate Posted October 26, 2010 Share Posted October 26, 2010 Well it all depens on what options your gona give them ... but something basic would probably be something like this: table = recipe id, user_id, title, recipe <form method="POST">Title: <input type="text" name="T1" size="20"><br> Recipe: <br> <textarea rows="20" name="S1" cols="48"></textarea><br> <input type="submit" value="Submit" name="B1"></form> INSERT INTO DATABASE <?php if ($_POST){ if ($_POST[title]==""){$err .= "You must provide a title for your recipe<br>";} if ($_POST[recipe]==""){$err .= "Your recipe is empty<br>";} if ($err){ echo $err; }else{ $insert = mysql_query("INSERT INTO recipe (id, user_id, title, recipe)VALUES ('', '$_SESSION[id]', '$_POST[title]', '$_POST[recipe]'") } } ?> SHOW LISTE FOR USER <?php echo '<table border="1" width="100%">'; $select = mysql_query("SELECT * FROM recipe WHERE user_id='$_SESSION[id]'") or die(mysql_error()); while ($recipe = mysql_fetch_array($select)) { echo "<tr><td>$recipe[title]</td></tr>"; } echo '</table>'; ?> Those are just basic exemples. You need to sanitize your stuff but i hope thats the kick you were asking for. Have fun and learn a lot :-) Quote Link to comment https://forums.phpfreaks.com/topic/216871-mysql-and-php-help/#findComment-1126658 Share on other sites More sharing options...
lmcgr44 Posted October 27, 2010 Author Share Posted October 27, 2010 hey thanks for your reply i am useing the code you gave me and it come up with error unexpected < . this is my code <? if($session->logged_in){ echo "<h1>Logged In</h1>"; echo "Welcome <b>$session->username</b>, you are logged in. <br><br>" ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] " ."[<a href=\"useredit.php\">Edit Account</a>] "; if($session->isAdmin()){ echo "[<a href=\"admin/admin.php\">Admin Center</a>] "; } echo "[<a href=\"process.php\">Logout</a>]"; } else{ <form method="POST" Title: <input type="text" name="T1" size="20"><br> Recipe: <br> <textarea rows="20" name="S1" cols="48"></textarea><br> <input type="submit" value="Submit" name="B1"></form> thank-you Quote Link to comment https://forums.phpfreaks.com/topic/216871-mysql-and-php-help/#findComment-1127062 Share on other sites More sharing options...
revraz Posted October 27, 2010 Share Posted October 27, 2010 When reporting errors, report the exact error and provide the line it's erroring on. Quote Link to comment https://forums.phpfreaks.com/topic/216871-mysql-and-php-help/#findComment-1127067 Share on other sites More sharing options...
Pikachu2000 Posted October 27, 2010 Share Posted October 27, 2010 Before you can echo anything, you either need to issue an 'echo', or drop out of php. It looks like the second option is what was intended here, so after the else { put in a closing php tag ?> and see if that takes care of it. Quote Link to comment https://forums.phpfreaks.com/topic/216871-mysql-and-php-help/#findComment-1127088 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.