Forum Moderators: coopster
Form Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Home Pages Text</title>
<style>
#form1 { background:#CCCCCC;
font-family:Georgia, "Times New Roman", Times, serif;
padding-left:10px;
}
</style>
</head>
<body>
<form action="testcommit.php"method="post">
<fieldset><legend>Website Text</legend>
<p>Website -
<select name="websites" id="websites" value="websites">
<option>Please Select One</option>
<option value="TMI">Teen Missions</option>
<option value="aosc">AIDS Orphans</option>
</select>
</p>
<p>Page -
<select name="page" value="page">
<option>Please Select One</option>
<option value="tmihome">TMI Home Page</option>
<option value="aoschome">AOSC Home Page</option>
<option value="ftm">FTM Page</option>
<option value="bmw">BMW Page</option>
</select>
</p>
<p>
<label>
<input name="Publishing" type="radio" value="Draft" checked="checked" />
Draft</label>
<label>
<input type="radio" name="Publishing" value="Publish" />
Publish</label>
<label>
<input type="radio" name="Publishing" value="Unpublish" />
Unpublish</label>
</p>
<p>
<label>Text Title :</label>
<input name="title" type="text" id="title" value="" size="30" maxlength="100" />
(*Note Text Title will Not Be shown on website)</p>
<p>
<textarea name="webtext" cols="50" rows="10"></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Submit" /> <input type="Reset" name="Reset" value="Reset" />
</p>
</fieldset>
</form>
</body>
</html>
PHP connecting to database to insert:
<?php
$link=mysql_connect("***","***","***")
or die ("Could not Connect Mayday:".mysql_error());
mysql_select_db('elisha', $link)
or die ("wheres elisha:".mysql_error());
// add the new information into the database
mysql_query ("INSERT INTO maintext (website, page, publishing, title, webtext)
VALUES ('$_POST[website]', '$_POST[page]', '$_POST[publishing]', '$_POST[title]', '$_POST[webtext]') ");
echo "<br />";
echo "<a href=\"form_page.php\">Click here to return to the form page.</a>";
?><pre>DEBUG:
<?php
print_r($_POST);
?></pre>
<p align="center" style="color:#0000FF"> Done. <a href="Textadd.php">Return to ADD </a>
</p>
</body>
</html>
Welcome to WebmasterWorld, Light_Gear.
One way to catch these errors right off during development is to turn on error_reporting [php.net]. This and more good tips on Troubleshooting [webmasterworld.com] can be found in our PHP Forum Library [webmasterworld.com].