gax
08-01-2008, 03:49 PM
What the program will do:
This program as of now asks the user to input there userid into box, browse for the file to upload, and then asks for a description. When you click upload it connects to our oracle db, inserts the values into the table, disconnects, and saves it.
Problem:
We want the userid to be pulled from the url and passed into the form "add_acq.php" instead of the user inputting there userid into the box.
So for example:
http://www.blah.com/?userid="blah"
It will pull "user" and pass it into the oracle db. So i want to make the userid box disappear so it grabs the userid from the url and passes it. I am running apache 2.2.4 and PHP 5.2.6. Any help would be much appriciated.
<html>
<form enctype="multipart/form-data" action="add_acq.php" method="POST">
<p align="center" style="margin-bottom: 0"><font face="Arial">Enter
EPS userid:</font></p>
<p align="center" style="margin-top: 0; margin-bottom: 0"><font face="Arial"><input type="text" name="userid" size="20">
<br>
<p align="center"><i><b><font face="Verdana" size="4" color="#003399">
Engineering Property System - Upload a File</font></b></i></p>
<br>
<p align="center">Select a File:</font></p>
<p align="center" style="margin-top: 0"><font face="Arial">
<input type="file" name="filename" size="20"></font></p>
<p align="center" style="margin-bottom: 0"><font face="Arial">File Description:</font></p>
<p align="center" style="margin-top: 0"><font face="Arial">
<input type="text" name = "descrip" size="20"></font></p>
<p align="center">
<input type="submit" value="Upload File"></p>
</form>
</html>
This goes to: add_acq.php
<?php
//This is the directory where images will be saved
$target = "E:/docs/acq08/".$HTTP_POST_FILES['filename']['name'];
//This gets all the other information from the form
$userid=$_POST['userid'];
$descrip=$_POST['descrip'];
$file=($_FILES['filename']['name']);
// Connects to the Database
if ($c=OCILogon("eps_attach", "eps_attach", "epsdev"))
{
echo "Successfully connected to EPS.\n <BR/><BR/>";
}
else
{
$err = OCIError();
echo "Oracle Connection Error <BR/>" . $err[text];
}
//Writes the information to the database
$s = OCIParse($c, "insert into eps.upload_attach values ('$userid', '$file', '$descrip', sysdate, 'ACQ', null)");
OCIExecute($s, OCI_DEFAULT);
//echo "EPS Attachment record created.<BR/>\n";
OCICommit($c);
//Writes the file to the server
if(move_uploaded_file($_FILES['filename']['tmp_name'], $target))
{
//Tells you if its all ok
echo "Your file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added.<BR/><BR/>Please close this window, and Save the information in EPS.<BR/><BR/>";
}
else {
//Gives an error if it is not
echo "Sorry, there was a problem uploading your file.<BR/> <BR/> <BR/> <BR/> <BR/> <BR/>";
}
?>
This program as of now asks the user to input there userid into box, browse for the file to upload, and then asks for a description. When you click upload it connects to our oracle db, inserts the values into the table, disconnects, and saves it.
Problem:
We want the userid to be pulled from the url and passed into the form "add_acq.php" instead of the user inputting there userid into the box.
So for example:
http://www.blah.com/?userid="blah"
It will pull "user" and pass it into the oracle db. So i want to make the userid box disappear so it grabs the userid from the url and passes it. I am running apache 2.2.4 and PHP 5.2.6. Any help would be much appriciated.
<html>
<form enctype="multipart/form-data" action="add_acq.php" method="POST">
<p align="center" style="margin-bottom: 0"><font face="Arial">Enter
EPS userid:</font></p>
<p align="center" style="margin-top: 0; margin-bottom: 0"><font face="Arial"><input type="text" name="userid" size="20">
<br>
<p align="center"><i><b><font face="Verdana" size="4" color="#003399">
Engineering Property System - Upload a File</font></b></i></p>
<br>
<p align="center">Select a File:</font></p>
<p align="center" style="margin-top: 0"><font face="Arial">
<input type="file" name="filename" size="20"></font></p>
<p align="center" style="margin-bottom: 0"><font face="Arial">File Description:</font></p>
<p align="center" style="margin-top: 0"><font face="Arial">
<input type="text" name = "descrip" size="20"></font></p>
<p align="center">
<input type="submit" value="Upload File"></p>
</form>
</html>
This goes to: add_acq.php
<?php
//This is the directory where images will be saved
$target = "E:/docs/acq08/".$HTTP_POST_FILES['filename']['name'];
//This gets all the other information from the form
$userid=$_POST['userid'];
$descrip=$_POST['descrip'];
$file=($_FILES['filename']['name']);
// Connects to the Database
if ($c=OCILogon("eps_attach", "eps_attach", "epsdev"))
{
echo "Successfully connected to EPS.\n <BR/><BR/>";
}
else
{
$err = OCIError();
echo "Oracle Connection Error <BR/>" . $err[text];
}
//Writes the information to the database
$s = OCIParse($c, "insert into eps.upload_attach values ('$userid', '$file', '$descrip', sysdate, 'ACQ', null)");
OCIExecute($s, OCI_DEFAULT);
//echo "EPS Attachment record created.<BR/>\n";
OCICommit($c);
//Writes the file to the server
if(move_uploaded_file($_FILES['filename']['tmp_name'], $target))
{
//Tells you if its all ok
echo "Your file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added.<BR/><BR/>Please close this window, and Save the information in EPS.<BR/><BR/>";
}
else {
//Gives an error if it is not
echo "Sorry, there was a problem uploading your file.<BR/> <BR/> <BR/> <BR/> <BR/> <BR/>";
}
?>