Hey. Ive never worled with php form file uploading and im just starting with mysql so can someone tell me if im doing this right? This is the forms page:
<html>
<head>
<title>Rampt Studios Comic Updater</title>
</head>
<body>
<form action="process.php" method="post" enctype="multipart/form-data">
Name of Comic:<br>
<input type="text" name="title"><br>
Authors Comments:<br>
<input type="text" name="comments"><br>
<input type="file" name="comic">
<input type="submit" name="Submit">
</form>
</body>
</html>
And here is the processing page:
<?php
if(isset( $Submit ))
{
copy ($_FILES['comic']['tmp_name'], "files/".$_FILES['comic']['name'])
or die ("Could not copy");
echo "Name: ".$_FILES['comic']['name']."";
echo "Size: ".$_FILES['comic']['size']."";
echo "Type: ".$_FILES['comic']['type']."";
echo "Copy Done....";
}
include("config.php");
$date=date("m/d/y");
mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_name);
INSERT INTO comic('','title','filename','date','comments');
VALUES('','$_POST[title],'files/".$_FILES['comic']['name']."','$date','$_POST[comments]');
?>
This is going to be for a comic updating script similiar to what drunkduck.com uses.You've pretty much got it.
<?php
if(isset( $Submit ))
{
copy ($_FILES['comic']['tmp_name'], "files/".$_FILES['comic']['name'])
or die ("Could not copy");
echo "Name: ".$_FILES['comic']['name']."";
echo "Size: ".$_FILES['comic']['size']."";
echo "Type: ".$_FILES['comic']['type']."";
echo "Copy Done....";
}
include("config.php");
$date=date("m/d/y");
mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_name);
mysql_query("INSERT INTO comic('title','filename','date','comments') VALUES('".$_POST[title]."','files/".$_FILES['comic']['name']."','$date','".$_POST[comments]."');") or die("Couldn't add to db: ".mysql_error());
?>
Not sure why you had those empty column/data references in your query though.this part
if(isset( $Submit ))
assumes you have register_globals on, which is off by default.
It should be
if(isset( $_POST['submit'] ))Thanks I think I finally understand mysql.Oh and if you want to see the comic Im making this for the link to my comic is in my sig, Omega Theatre
<html>
<head>
<title>Rampt Studios Comic Updater</title>
</head>
<body>
<form action="process.php" method="post" enctype="multipart/form-data">
Name of Comic:<br>
<input type="text" name="title"><br>
Authors Comments:<br>
<input type="text" name="comments"><br>
<input type="file" name="comic">
<input type="submit" name="Submit">
</form>
</body>
</html>
And here is the processing page:
<?php
if(isset( $Submit ))
{
copy ($_FILES['comic']['tmp_name'], "files/".$_FILES['comic']['name'])
or die ("Could not copy");
echo "Name: ".$_FILES['comic']['name']."";
echo "Size: ".$_FILES['comic']['size']."";
echo "Type: ".$_FILES['comic']['type']."";
echo "Copy Done....";
}
include("config.php");
$date=date("m/d/y");
mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_name);
INSERT INTO comic('','title','filename','date','comments');
VALUES('','$_POST[title],'files/".$_FILES['comic']['name']."','$date','$_POST[comments]');
?>
This is going to be for a comic updating script similiar to what drunkduck.com uses.You've pretty much got it.
<?php
if(isset( $Submit ))
{
copy ($_FILES['comic']['tmp_name'], "files/".$_FILES['comic']['name'])
or die ("Could not copy");
echo "Name: ".$_FILES['comic']['name']."";
echo "Size: ".$_FILES['comic']['size']."";
echo "Type: ".$_FILES['comic']['type']."";
echo "Copy Done....";
}
include("config.php");
$date=date("m/d/y");
mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_name);
mysql_query("INSERT INTO comic('title','filename','date','comments') VALUES('".$_POST[title]."','files/".$_FILES['comic']['name']."','$date','".$_POST[comments]."');") or die("Couldn't add to db: ".mysql_error());
?>
Not sure why you had those empty column/data references in your query though.this part
if(isset( $Submit ))
assumes you have register_globals on, which is off by default.
It should be
if(isset( $_POST['submit'] ))Thanks I think I finally understand mysql.Oh and if you want to see the comic Im making this for the link to my comic is in my sig, Omega Theatre