For those of you that read about the website I want to redo, I have gotten permission to start on a prototype for a new website!

The website has 30 to 40 articles that can be quite long. My initial idea was to build a php form to input the html of the articles into MySQL, but when I did a GET, it said that the URL was too long. So I switched the exact code to a POST instead. There was no error, but it didn't add anything to the database either. Anyone have experience with this.

Here is the code --->

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html>
<head>
        <title>Western Botanicals - Add Information</title>
</head>
<body>
        <h1>Add Information</h1>
        <?php
                // include the database connections
                include("../includes/dbconnect.php");
                // add product type if not found
                if (isset($_POST['informationtitle'])) {
                        // get all of the input
                        $informationtitle = ($_POST['informationtitle']);
                        $informationhtml = ($_POST['informationhtml']);
                        $informationtype = ($_POST['informationtype']);
                        $informationdate = ($_POST['informationdate']);
                        
                        // Format time to timestamp
                        $m = substr($informationdate, 0, 2);
                        $d = substr($informationdate, 3, 2);
                        $y = substr($informationdate, 6, 10);
$informationdatestamp = mktime(0, 0, 0, date($m), date($d), date ($y));
                
$sql = "SELECT * FROM Information WHERE Information_Title = ('$informationtitle')";
                        $result = @mysql_query($sql);
                        while ($row = mysql_fetch_array($result)) {
                                $informationnamefound = $row['Information_ID'];
                        }
                        if ($informationnamefound > 0) {
                                echo 'Information not entered. Already found.';
                        } else {
$sql = "INSERT INTO Information VALUES ('i','$informationtitle', '$informationhtml', '$informationtype', '$informationdatestamp')";
                                $result = @mysql_query($sql);
                                echo 'Information "' . $informationtitle . '" 
added';
                        }
                }
                
                echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'">';
echo 'Information Title: <input type="text" name="informationtitle" value="" /><br />'; echo 'Information HTML: <textarea name="informationhtml" rows="30" cols="70"></textarea><br />'; echo 'Information Date (mm/dd/yyyy): <input type="text" name="informationdate" value="" /><br />';
                $sql = "SELECT * FROM Information_Types";
                $result = @mysql_query($sql);
                while ($row = mysql_fetch_array($result)) {
echo '<input type="radio" name="informationtype" value="' . $row ['Information_Type_ID'] . '" />' . $row['Information_Type_Name'] . '<br />';
                }
                echo '<input type="submit" value="Add" />';
                echo '</form>';
        ?>
</body>
</html>


Justin Giboney





_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to