hey, ive knocked the following up from many different sites, a clump of it I found just a second ago on these forums. I understand the vast magority of the code. and some of it works... some of it doesnt 🙂
ive got a list that comes up with information from the sql database, wicked. but then I get :
Notice: Undefined variable: submit in W:\admin\als\members\and_tutadd.php on line 30
and the form.
When I submit the form, I get a 404. any suggestions?
<?PHP
$reqlevel = 2;
include("membersonly.inc.php");
$db = mysql_connect("localhost", "----", "----");
mysql_select_db("andromeda_news",$db);
$result = mysql_query("SELECT * FROM news",$db);
while ($row = mysql_fetch_array($result))
{
printf ("%s %s %s<br>", $row["ID"], $row["Title"], $row["Content"]);
}
?>
<html>
<body>
<?php
if ($submit) {
// process form
$db = mysql_connect("localhost", "----", "----") or die("Could Not Connect To The Database. <br>" . mysql_error());
mysql_select_db("andromeda_news",$db) or die("Could Not Select The Proper Database. <br>" . mysql_error());
$name = $POST['name'];
$desc = $POST['desc'];
$url = $_POST['url'];
$sql = "INSERT INTO news(Title, Content) VALUES ('$name','$desc','$url')";
$result = mysql_query($sql);
if($result)
{
echo "Data Properly Inserted";
}
else
{
echo "An Error occured while trying to process your information.";
}
echo $sql ;
echo "Thank you! Information entered.\n";
}
else
{
// display form
?>
<form method="post" action="<?php echo $PHP_SELF?>">
title:<input type="Text" name="name"><br>
content:<input type="Text" name="desc"><br>
<input type="Submit" name="submit" value="Enter information">
</form>
<?php
} // end if
?>