Greetings:
I've been working on this code for quite some time now. If you can provide any assistance I would be most gracious.
When an admin logs into the site he/she has the option to upload pdf documents to a users folder. So I have displayed all the users within the database along with a radio button beside each username. See code below...
The code above displays the users successfully. Now I would like the admin to select the user he wishes to upload the documents.PHP Code:include "../includes/connect_to_mysql.php";
$table = 'users';
// sending query
$result = mysql_query("SELECT id_user, name, email FROM {$table}");
if (!$result) {
die("Query to show fields from table failed");
}
echo "<h2>Your Customers</h2><br />";
echo "<table width='90%' cellpadding='20' cellspacing='11' border='1'><tr>";
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$id_user=mysql_result($result,$i,"id_user");
$name=mysql_result($result,$i,"name");
$email=mysql_result($result,$i,"email");
echo "<form name='form3' enctype='multipart/form-data' method='post' action='upload.php'>";
echo "<td style='border-color:#8db2f5; padding-left:10px; padding-right:10px'>";
echo "<input type='radio' name='email' >";
echo "$name";
echo "</td>";
echo "<td style='border-color:#8db2f5; padding-left:10px; padding-right:10px'>";
echo "$email";
echo "</td>";
echo "</tr>\n";
$i++;
}
echo "</table>";
mysql_free_result($result);
Next the admin chooses the documents and proceed to submit/upload. See code below...
PHP Code:$client_upload_doc ="<br /><br /><h2>Client Upload</h2><br />
<fieldset>
<legend>Multiple upload</legend>
<p>Pick up some files to upload, and press 'upload' </p>
<p><input type='file' size='32' name='my_field[]' value='' /></p>
<p><input type='file' size='32' name='my_field[]' value='' /></p>
<p><input type='file' size='32' name='my_field[]' value='' /></p>
<p class='button'><input type='hidden' name='action' value='multiple' />
<input type='submit' name='Submit' value='upload customer documents' /></p>
</form>
</fieldset>";
echo $client_upload_doc;
The Problem:
While the upload process works perfectly when i assign it to a folder, I would like it to upload to the selected user's folder the admin has chosen using the radio button. See code below...
I've tried this: Yet unsuccessful
When I echo $email it I get an error. How can I capture $email and use it to upload to the folder on the server?PHP Code:$email = $_POST['email'];
$the_user_email_folder = "$email";
$dir_dest = (isset($_GET['dir']) ? $_GET['dir'] :"members/$the_user_email_folder");
$dir_pics = (isset($_GET['pics']) ? $_GET['pics'] : $dir_dest);
This works Perfectly! (info@domain.net is the name of a folder on the server)
PHP Code:$the_user_email_folder = "info@ah-webdesign.net";
$dir_dest = (isset($_GET['dir']) ? $_GET['dir'] :"members/$the_user_email_folder");
$dir_pics = (isset($_GET['pics']) ? $_GET['pics'] : $dir_dest);
Thanks in advance


Reply With Quote

Bookmarks