Jump to content

MySql and php help


lmcgr44

Recommended Posts

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

Link to comment
Share on other sites

Link to comment
Share on other sites

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 :-)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.