I took what you said, edited it a tiny bit.
Im using my own form, set with
code:
method="post" action="<? echo $PHP_SELF; ?>"
with
code:
<?
require ("scripts/add.php");
?>
at the top of the page. Then in scripts/add.php, I have this:
code:
<?
require_once ("scripts/config.php");
$errors = array();
if ($_SERVER['REQUEST_METHOD']=="POST"){
$errors = process_form($errors);
}
function process_form($errors) {
$catid = $_REQUEST['catid'] ;
$mplink = $_REQUEST['mplink'] ;
$name = $_REQUEST['name'] ;
$dllink = $_REQUEST['dllink'] ;
$desc = $_REQUEST['desc'] ;
$pic = $_REQUEST['pic'] ;
if (empty($catid)) {
$errors["No catid"]="Empty catid";
}
if (empty($mplink)) {
$errors["No mplink"]="Empty mplink";
}
if (empty($name)) {
$errors["No name"]="Empty name";
}
if (empty($dllink)) {
$errors["No dllink"]="Empty dllink";
}
if (empty($desc)) {
$errors["No desc"]="Empty desc";
}
if (empty($pic)) {
$errors["No pic"]="Empty pic";
}
if (count($errors) == 0) {
mysql_query("INSERT INTO download_items (catid,mplink,name,dllink,desc,rate,type,pic) VALUES ('$catid','$mplink','$name','$dllink','$desc','$rate','$type,'$pic')");
header( "Location: scripts/add2.htm" );
}
return $errors;
}
function print_error($error) {
echo "<b><font color=red>Error/b> $error</font><br /><br />";
}
?>
but it doens't work. No errors, it does exactly what I want it to (check for missing fields, if none process, if some show error on the form). It just doesn't insert into the database, I have no idea why. Any ideas?? (rate and type dont need to be checked for missing feilds cause they are set to "Not Available by default".
(config hold the username, password and database name.) The code in it is:
code:
<?
$username ="******";
$password ="******";
$database="******";
$connection = mysql_connect("localhost","$username","$password");
@mysql_select_db("$database", $connection) or die( "<br><center><h2>Unable to select database, please refresh.</h2>If problem persists, please contact me using the form and report the error you are receiving if any.</center>");
?>
As for the slashes, how can I tell if I have magic quotes enabled??
So, if you find what is wrong, can you submit 2 versions, one with and one without slahes command thing, just in case.
As for what its for, adding downloads to my site.
catid = I have 8 different catagorys so catid is somewhere between 1-8
mplink = Main page link
name = Name of the download
dllink = Download link
desc = Description of the download
rate = My rating for the download
type = The type of download it is, Freeware, Shareware etc.
pic = A picture of the download
k776