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 [email protected]

 

thank-you for your help

Link to comment
https://forums.phpfreaks.com/topic/216871-mysql-and-php-help/
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
https://forums.phpfreaks.com/topic/216871-mysql-and-php-help/#findComment-1126658
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
https://forums.phpfreaks.com/topic/216871-mysql-and-php-help/#findComment-1127062
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/216871-mysql-and-php-help/#findComment-1127088
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.