Jump to content

camdenite

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

camdenite's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi, Thanks for that but how do I post that to the database? Can you point me in the direction of a tutorial? Thanks for your advice. Cheers, Colin
  2. I'm new to but this is an example of my blog edit page: if ($num > 0) { // If it ran OK, display the records. echo "<p>There are currntly $num Blog entries.</p>\n"; // Table header. echo '<table align="center" cellspacing="0" cellpadding="5"> <tr> <td align="left"><b>Date</b></td> <td align="left"><b>Heading</b></td> <td align="view"><b>View</b></td> <td align="left"><b>Edit</b></td> <td align="left"><b>Delete</b></td> </tr> '; // Fetch and print all the records. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo '<tr> <td align="left"><a href="blog_view.php?id=' . $row['blog_id'] . '">' . $row['date2'] . '</a></td> <td align="left">' . $row['heading'] . '</td> <td align="left"><a href="blog_view.php?id=' . $row['blog_id'] . '">View</a></td> <td align="left"><a href="blog_edit4b.php?id=' . $row['blog_id'] . '">Edit</a></td> <td align="left"><a href="delete_blog.php?id=' . $row['blog_id'] . '">Delete</a></td> </tr> '; } Hope this helps.
  3. Hi, I'm trying to create a date select box that will post to a table 'date2' but I am not sure how to create the php. I have done this: if(isset($_POST['submit'])) { $month=$_POST['month']; $dt=$_POST['dt']; $year=$_POST['year']; $date2="$month/$dt/$year"; I want all the data made into mm/dd/yyyy in the database table but not sure how to do that or what I am asking for. Please help. Cheers, Colin
  4. Hi all, I'm looking for an example or tutorial on how to create a browse image button that will post the link back to my form - without reloading. I'm not asking very well but I just want a blog creation page with a form (which I have got working thanks to this forum - cheers) and to be able to browse the images in my image folder, click on one and insert the link into the correct field. This can then be posted to the db. Can't seem to find a good example but I may be asking G the wrong Qs. Cheers
  5. I'm so thick - I'm surprised my bum doesn't fall off :-\ Thanks Deansatch - that sorted it. And my html. Cheers.
  6. I should say that first_para does post but that's in a textarea...
  7. Hi all, I've got this: <form action="create_blog.php" method="post"> <td>Category Code<br /> (enter 2-digit code from list on right):<br /> <input type="text" name="category_id" size="5"/></td></tr> <tr> <td valign="top">First Paragraph: <br /> <textarea name="first_para" cols="60" rows="6" /></textarea></td> very basically.The textarea posts but the input doesn't. I've also got this to go with it: // Check for a category_id. if (empty($_POST['category_id'])) { $errors[] = 'You forgot to enter a Category ID.'; } else { $header = escape_data($_POST['category_id']); } // Check for a page title. if (empty($_POST['first_para'])) { $errors[] = 'You forgot to enter a First Paragraph.'; } else { $first_para = escape_data($_POST['first_para']); } and this: $query = "INSERT INTO blogb (date2, heading, category_id, first_para, entry, more) VALUES ('$date2', '$heading', '$category_id', '$first_para', '$entry', '$more')"; $result = @mysql_query ($query); // Run the query. if ($result) { // If it ran OK. No errors so no idea why it doesn't insert category_id into the database. I put this in my script: ini_set ("display_errors", "1"); error_reporting(E_ALL); And there is nothing in the error log on the server. Please help. Cheers, Colin
  8. Cheers The code is to update table for a blog. The problem seems to be defining the rows - which I just thought I don't need to do. I am posting rows, or trying to, with this: <input type="text" name="category_id" size="5" value="'.$row['category_id'].'" /></td></tr> Which doesn't make any sense. I have to do something like: <input type="text" name="category_id" size="5" value="'. if (isset($_POST['pname'])) echo $_POST['pname'] .'" /></td></tr> Does that make sense?
  9. Should there be a SELECT * FROM blogb or do I have to set $header = $row['header'}; individually?
  10. Hi, Thanks for that. I got a few errors pointing to lines like: <input type="text" name="heading" size="70" value="'.$row['heading'].'" /> I don't think I have anything in the script fetching the records - while ($row = mysql_fetch_assoc($result)) { - but I don't know where to put it. Cheers
  11. Hi, I am completely lost as to why this is not creating new info on to the db. The script submits as if I don't fill out the form I get the errors. If I do I just get a blank page an it doesn't update the db... Nothing in the error log. I have been through this script but I am lost as to why it doesn't work and why there are no errors - wierd. Please help. <?php require_once ('mysql_connect.php'); // Connect to the db. // Check if the form has been submitted. if (isset($_POST['submitted'])) { $errors = array(); // Initialise error array. // Check for a page name. if (empty($_POST['heading'])) { $errors[] = 'You forgot to enter a Blog Header.'; } else { $header = escape_data($_POST['heading']); } // Check for a page title. if (empty($_POST['first_para'])) { $errors[] = 'You forgot to enter a First Paragraph.'; } else { $first_para = escape_data($_POST['first_para']); } // Check for Page Content. if (empty($_POST['entry'])) { $errors[] = 'You forgot to enter an Entry.'; } else { $entry = escape_data($_POST['entry']); } if (empty($errors)) { // If everything's OK. // Create the page in the database. /* Check for an existing page with the same name. $query = "SELECT blog_id FROM blogb WHERE heading='$heading'"; $result = mysql_query($query); if (mysql_num_rows($result) == 0) { */ // Make the query. $query = "INSERT INTO blogb (blog_id, date1, date2, heading, category_id, first_para, entry, more, image1, image2, image3, image4, pub2 ) VALUES ('$blog_id', '$date1', '$date2', '$heading', '$category_id', '$first_para', '$entry', '$more', '$image1', '$image2', '$image3', '$image4', '$pub2')"; $result = @mysql_query ($query); // Run the query. if ($result) { // If it ran OK. // Redirect the page_created.php page. // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/blog_created.php'; header("Location: $url"); exit(); } else { // If it did not run ok. $errors[] = 'The page could not be registered due to a system error. We appologise for any inconvenience.'; // Public message. $errors[] = mysql_error() . '<br /><br />Query: ' . $query; // Debugging message. } } else { // Page already exists. $errors[] = 'This page already exists.'; } /* } // End of empty if (empty(errors)) IF. */ } else { // Form has not been submitted. $errors = NULL; } // End of main submit conditional. // Begin the page now. $page_title = 'Blog Creator'; if (!empty($errors)) { // Print any error messages. echo '<h1>Error!</h1> <p>The following error(s) occurred:<br />'; foreach ($errors as $msg) { // Print each error. echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p>'; } // Create the form. echo '<form action="create_blog.php" method="post"> <table width="500px"> <tr> <td>Date: <b>'.$row['date2'].'</b><br /></td></tr> <tr> <td>Heading: <br /> <input type="text" name="heading" size="70" value="'.$row['heading'].'" /> </td> </tr> <tr> <td>Category Code<br /> (enter 2-digit code from list on right):<br /> <input type="text" name="category_id" size="5" value="'.$row['category_id'].'" /></td></tr> <tr> <td valign="top">First Paragraph: <br /> <textarea name="first_para" cols="60" rows="6" />'.$row['first_para'].'</textarea></td> </tr> <tr> <td valign="top">Entry: <br /> <textarea name="entry" cols="60" rows="10" />'.$row['entry'].'</textarea></td> </tr> <tr> <td valign="top">More: <br /> <textarea name="more" cols="60" rows="10" />'.$row['more'].'</textarea></td> </tr> <tr> <td>First Image: <br /> <input type="text" name="image1" size="70" value="'.$row['image1'].'" /> </td> </tr> <tr> <td>Second Image: <br /> <input type="text" name="image2" size="70" value="'.$row['image2'].'" /> </td> </tr> <tr> <td>Third Image: <br /> <input type="text" name="image3" size="70" value="'.$row['image3'].'" /> </td> </tr> <tr> <td> </tr> </tr> <tr> <td> <input type="submit" name="submitted" value="Submit" style="background:#ff0 none;" /> <input type="hidden" name="submitted" value="TRUE" /> </td> </tr> </table> </form>' ; ?>
  12. Sorry I'm posting a new error under an old post. I should start a new thread. Cheers.
  13. Try this: PHP and MySQL for Dynamic Web Sites - by Larry Ullman http://tinyurl.com/bxle6x But yes it's going to take you some time. Cheers
  14. Hi again, I am completely lost as to why this is not creating new info on to the db. The script submits as if I don't fill out the form I get the errors. If I do I just get a blank page an it doesn't update the db... Nothing in the error log. I have been through this script but I am lost as to why it doesn't work and why there are no errors - wierd. Please help. Cheers. <?php require_once ('mysql_connect.php'); // Connect to the db. // Check if the form has been submitted. if (isset($_POST['submitted'])) { $errors = array(); // Initialise error array. // Check for a page name. if (empty($_POST['heading'])) { $errors[] = 'You forgot to enter a Blog Header.'; } else { $header = escape_data($_POST['heading']); } // Check for a page title. if (empty($_POST['first_para'])) { $errors[] = 'You forgot to enter a First Paragraph.'; } else { $first_para = escape_data($_POST['first_para']); } // Check for Page Content. if (empty($_POST['entry'])) { $errors[] = 'You forgot to enter an Entry.'; } else { $entry = escape_data($_POST['entry']); } if (empty($errors)) { // If everything's OK. // Create the page in the database. /* Check for an existing page with the same name. $query = "SELECT blog_id FROM blogb WHERE heading='$heading'"; $result = mysql_query($query); if (mysql_num_rows($result) == 0) { */ // Make the query. $query = "INSERT INTO blogb (blog_id, date1, date2, heading, category_id, first_para, entry, more, image1, image2, image3, image4, pub2 ) VALUES ('$blog_id', '$date1', '$date2', '$heading', '$category_id', '$first_para', '$entry', '$more', '$image1', '$image2', '$image3', '$image4', '$pub2')"; $result = @mysql_query ($query); // Run the query. if ($result) { // If it ran OK. // Redirect the page_created.php page. // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/blog_created.php'; header("Location: $url"); exit(); } else { // If it did not run ok. $errors[] = 'The page could not be registered due to a system error. We appologise for any inconvenience.'; // Public message. $errors[] = mysql_error() . '<br /><br />Query: ' . $query; // Debugging message. } } else { // Page already exists. $errors[] = 'This page already exists.'; } /* } // End of empty if (empty(errors)) IF. */ } else { // Form has not been submitted. $errors = NULL; } // End of main submit conditional. // Begin the page now. $page_title = 'Blog Creator'; if (!empty($errors)) { // Print any error messages. echo '<h1>Error!</h1> <p>The following error(s) occurred:<br />'; foreach ($errors as $msg) { // Print each error. echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p>'; } // Create the form. echo '<form action="create_blog.php" method="post"> <table width="500px"> <tr> <td>Date: <b>'.$row['date2'].'</b><br /></td></tr> <tr> <td>Heading: <br /> <input type="text" name="heading" size="70" value="'.$row['heading'].'" /> </td> </tr> <tr> <td>Category Code<br /> (enter 2-digit code from list on right):<br /> <input type="text" name="category_id" size="5" value="'.$row['category_id'].'" /></td></tr> <tr> <td valign="top">First Paragraph: <br /> <textarea name="first_para" cols="60" rows="6" />'.$row['first_para'].'</textarea></td> </tr> <tr> <td valign="top">Entry: <br /> <textarea name="entry" cols="60" rows="10" />'.$row['entry'].'</textarea></td> </tr> <tr> <td valign="top">More: <br /> <textarea name="more" cols="60" rows="10" />'.$row['more'].'</textarea></td> </tr> <tr> <td>First Image: <br /> <input type="text" name="image1" size="70" value="'.$row['image1'].'" /> </td> </tr> <tr> <td>Second Image: <br /> <input type="text" name="image2" size="70" value="'.$row['image2'].'" /> </td> </tr> <tr> <td>Third Image: <br /> <input type="text" name="image3" size="70" value="'.$row['image3'].'" /> </td> </tr> <tr> <td> </tr> </tr> <tr> <td> <input type="submit" name="submitted" value="Submit" style="background:#ff0 none;" /> <input type="hidden" name="submitted" value="TRUE" /> </td> </tr> </table> </form>' ; ?>
  15. Ok here goes - I'm not brilliant at this but: <?php // Create a login/logout link. if ( (isset($_SEESION['login'])) $$ (!strpos($_SERVER['PHP_SELF'], 'logout.php')) ) { echo '<a href="logout.php title="Logout">Logout</a>'; } else { echo '<a href="login.php" title="login">login</a>'; } ?> Hope this helps - appologies for posting before I finished. I couldn't work out how you login but I'm sure you can adapt the script. Taken from PHP And MySQL for Dynamc Websites by Larry Ullman. Cheers, Colin
×
×
  • 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.