Please help simple for a lot of you
Posted: Sat Apr 01, 2006 10:44 pm
Ok so im a complete noob when it comes to php done a lot of stuff in vbscript but not a lot in php told it wasn't to different but anyways to the point im trying to add news to a database but i cant seem to get this to work and i have no clue why...
User name and password were removed by me. Thanks for the help
Code: Select all
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<?
if($_POST['submit']) //If submit is hit
{
mysql_connect("localhost","uname","pass");
mysql_select_db("news");
$title = $_POST['title'];
$desc = $_POST['desc'];
$result=MYSQL_QUERY("INSERT INTO news (id,title,desc)".
"VALUES ('NULL', '$title', '$desc')");
echo "Finished";
}
else
{
?>
<form method="post" action="add.php">
<TABLE>
<TR>
<TD>Title:</TD>
<TD><INPUT TYPE='TEXT' NAME='title' VALUE='' size=60></TD>
</TR>
<TR>
<TD>News:</TD>
<TD><INPUT TYPE='TEXT' NAME='desc' VALUE='' size=60></TD>
</TR><br>
<TR>
<TD></TD><br>
<TD><INPUT TYPE="submit" name="submit" value="submit"></TD>
</TR>
</TABLE>
</form>
<?
}
?>
</body>
</html>