Chubichan Posted January 12, 2009 Share Posted January 12, 2009 Am I doing this correctly? I am using a cms to update a client's web site. I want the database to populate the cms text boxes so that I can quickly see and update the website content quickly and easily. The client will also be using this cms to do so herself. From what I have researched on the internet this is supposedly the correct way to accomplish this. Please anyone take a look and help me if you can. The text boxes are still blank and there is data in the database that it should be pulling into the textareas. <!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>Dr. Michael D. Doyle | Payment Information</title> <LINK REL=StyleSheet HREF="content_management.css" TYPE="text/css" /> </head> <body> <div id="container"> <h3>Michael D. Doyle Content Management System</h3> <div id="form_wrapper"> <form method="post" action="put.php"> <div><label for="index">Homepage</label><textarea name="home" rows="15" cols="70" ><?php echo $home ?> </textarea></div> <div><label for="mot">Meet Our Team</label><textarea name="mot" rows="15" cols="70" ><?php echo $mot ?> </textarea></div> <div><label for="pf">Patient Forms</label><textarea name="pf" rows="15" cols="70" ><?php echo $pf ?> </textarea></div> <div><label for="fi">Financial Information</label><textarea name="fi" rows="15" cols="70" ><?php echo $fi ?> </textarea></div> <div><label for="loc">Locations</label><textarea name="loc" rows="15" cols="70" ><?php echo $loc ?> </textarea></div> <div><label for="con">Contact</label><textarea name="con" rows="15" cols="70"><?php echo $con ?> </textarea></div> <div><label for="ms">Mission Statement</label><textarea name="ms" rows="15" cols="70" ><?php echo $ms ?> </textarea></div> <div><label for="dis">Disclaimer</label><textarea name="dis" rows="15" cols="70" ><?php echo $dis ?> </textarea></div> <div class="actions"><input type="submit" name="submit" value="Submit Content" class="submit"/></div> </form> </div> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 12, 2009 Share Posted January 12, 2009 That looks fine. The problem is probably in the code you have to declare those variables - which you did not provide. Quote Link to comment Share on other sites More sharing options...
abdfahim Posted January 12, 2009 Share Posted January 12, 2009 Are you sure you have values in those php variables? I doubt because I dont see anything wrong in the HTML syntax. You try echo those php variables first outside the form and see whether they print anything. Quote Link to comment Share on other sites More sharing options...
Chubichan Posted January 12, 2009 Author Share Posted January 12, 2009 That looks fine. The problem is probably in the code you have to declare those variables - which you did not provide. Very sorry but could you provide an example? This is my very first cms ??? Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 12, 2009 Share Posted January 12, 2009 An example of what? Where is your code for defining the variables such as $home? I have no clue as to your datasse structure or design. Assuming these values are contained within a table with a single record (each column in the table represents a different value above). And, I will assume that the column (field) names in the table are exactly the same as the variable names above. <?php //Connect to the database server $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } //Select the database mysql_select_db("my_db", $link) or die('Could not connect to db: ' . mysql_error()); //Query the database $query = "SELECT * FROM `table'"; $result = mysql_query($query) or die('Error running query: ' . mysql_error()); //Get the results $record = mysql_fetch_assoc($result); //Puts the result values into variables with same names as the field names ectract($record); ?> <!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>Dr. Michael D. Doyle | Payment Information</title> <link rel="stylesheet" href="content_management.css" TYPE="text/css" /> </head> <body> <div id="container"> <h3>Michael D. Doyle Content Management System</h3> <div id="form_wrapper"> <form method="post" action="put.php"> <div><label for="index">Homepage</label><textarea name="home" rows="15" cols="70" ><?php echo $home ?> </textarea></div> <div><label for="mot">Meet Our Team</label><textarea name="mot" rows="15" cols="70" ><?php echo $mot ?> </textarea></div> <div><label for="pf">Patient Forms</label><textarea name="pf" rows="15" cols="70" ><?php echo $pf ?> </textarea></div> <div><label for="fi">Financial Information</label><textarea name="fi" rows="15" cols="70" ><?php echo $fi ?> </textarea></div> <div><label for="loc">Locations</label><textarea name="loc" rows="15" cols="70" ><?php echo $loc ?> </textarea></div> <div><label for="con">Contact</label><textarea name="con" rows="15" cols="70"><?php echo $con ?> </textarea></div> <div><label for="ms">Mission Statement</label><textarea name="ms" rows="15" cols="70" ><?php echo $ms ?> </textarea></div> <div><label for="dis">Disclaimer</label><textarea name="dis" rows="15" cols="70" ><?php echo $dis ?> </textarea></div> <div class="actions"><input type="submit" name="submit" value="Submit Content" class="submit"/></div> </form> </div> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
Chubichan Posted January 12, 2009 Author Share Posted January 12, 2009 An example of what? Where is your code for defining the variables such as $home? I have no clue as to your datasse structure or design. Assuming these values are contained within a table with a single record (each column in the table represents a different value above). And, I will assume that the column (field) names in the table are exactly the same as the variable names above. <?php //Connect to the database server $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } //Select the database mysql_select_db("my_db", $link) or die('Could not connect to db: ' . mysql_error()); //Query the database $query = "SELECT * FROM `table'"; $result = mysql_query($query) or die('Error running query: ' . mysql_error()); //Get the results $record = mysql_fetch_assoc($result); //Puts the result values into variables with same names as the field names ectract($record); ?> <!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>Dr. Michael D. Doyle | Payment Information</title> <link rel="stylesheet" href="content_management.css" TYPE="text/css" /> </head> <body> <div id="container"> <h3>Michael D. Doyle Content Management System</h3> <div id="form_wrapper"> <form method="post" action="put.php"> <div><label for="index">Homepage</label><textarea name="home" rows="15" cols="70" ><?php echo $home ?> </textarea></div> <div><label for="mot">Meet Our Team</label><textarea name="mot" rows="15" cols="70" ><?php echo $mot ?> </textarea></div> <div><label for="pf">Patient Forms</label><textarea name="pf" rows="15" cols="70" ><?php echo $pf ?> </textarea></div> <div><label for="fi">Financial Information</label><textarea name="fi" rows="15" cols="70" ><?php echo $fi ?> </textarea></div> <div><label for="loc">Locations</label><textarea name="loc" rows="15" cols="70" ><?php echo $loc ?> </textarea></div> <div><label for="con">Contact</label><textarea name="con" rows="15" cols="70"><?php echo $con ?> </textarea></div> <div><label for="ms">Mission Statement</label><textarea name="ms" rows="15" cols="70" ><?php echo $ms ?> </textarea></div> <div><label for="dis">Disclaimer</label><textarea name="dis" rows="15" cols="70" ><?php echo $dis ?> </textarea></div> <div class="actions"><input type="submit" name="submit" value="Submit Content" class="submit"/></div> </form> </div> </div> </body> </html> Thanks for the help, like I said I am building my first cms. I am just going by books I have purchased and tutorials at the moment. Quote Link to comment 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.