Upload Add Form
11 posts by 5 authors in: Forums > CMS Builder
Last Post: December 28, 2012 (RSS)
By design9 - July 28, 2011
It works great but it outputs the array on the user form page. Should that be hidden? What do I need to input so that doesn't show on the form?
See example:
http://www.charlotteparent.com/photos/form.php
How do you add additional fields that you have created so that is written to database like the title field? I have some basic additional fields like name, email in the form that I want to add (and are in my section editor). Also, how would I add the category dropdown that I have created in the backend (I used the advanced list option to pull that dropdown into my backend photo section). I want to include this same dropdown on the form that users submit to upload their photo and information so it automatically applies it to that category in database/backend.
Thanks!
April
Re: [design9] Upload Add Form
By Jason - July 29, 2011
To get rid of the "Array()" at the top of the page remove this line:
print_r($_FILES);
You have to manually add fields to the form. For example, if you have a drop down in your section called category, you can add it like this:
<tr>
<td valign="top">Title</td>
<td><input class="text-input medium-input" type="text" name="title" value="<?php echo htmlspecialchars(@$_REQUEST['title']) ?>" size="30" /></td>
</tr>
<tr>
<td valign="top">Category</td>
<td>
<select name = "category">
<?php foreach (getListOptions('tableName', 'category') as $value => $label): ?>
<option value = "<?php echo $value;?>" <?php selectedIf($value, @$_REQUEST['category']);?>> <?php echo $label;?> </option>
<?php endforeach ?>
</select>
</td>
</tr>
You have to change 'tableName' with the name of your table.
you can then add this to the sql query like this:
$query = "INSERT INTO `{$TABLE_PREFIX}$tableName` SET
createdDate = NOW(),
createdByUserNum = '" .intval( @$CURRENT_USER['num'] ). "',
updatedDate = NOW(),
updatedByUserNum = '" .intval( @$CURRENT_USER['num'] ). "',
category = '".mysql_escape(@$_REQUEST['category'])."',
title = '".mysql_escape( $_REQUEST['title'] )."'";
Hope this helps.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Upload Add Form
By Toledoh - August 3, 2011
table: project_list
value: num
label: title
In an update form, I use the following code to display a radio list;
<td>
<?php $fieldname = 'category'; ?>
<?php $idCounter = 0; ?>
<?php foreach (getListOptions('accounts', $fieldname) as $value => $label): ?>
<?php $id = "$fieldname." . ++$idCounter; ?>
<input type="radio" name="<?php echo $fieldname ?>" id="<?php echo $id ?>"
value="<?php echo htmlspecialchars($value) ?>" <?php checkedIf(@$_REQUEST[$fieldname], $value) ?> />
<label for="<?php echo $id ?>"><?php echo htmlspecialchars($label) ?></label><br/>
<?php endforeach ?>
</td>
How do I show in the form only the items selected in the admin for that user?
So the projects may be project a, project b, project c. That user has been identified to have access to project a and project b, not project c. When they use the form, I don't want them to be able to see "project c".
Tim (toledoh.com.au)
Re: [Toledoh] Upload Add Form
By Jason - August 4, 2011
Assuming that the $value in your loop will match the "num" stored in project, you can convert the project stored in CURRENT_USER into an array and check to see if the current $value matches anything stored in that array.
I did notice that you're outputting your radio buttons from the "category" field. Does that match the "project" field?
Here is an example of the code you can use:
<td>
<?php
$fieldname = 'category';
$idCounter = 0;
$selectedProjects = explode("\t", trim($CURRENT_USER['project'], "\t"));
?>
<?php foreach (getListOptions('accounts', $fieldname) as $value => $label): ?>
<?php if (!in_array($value, $selectedProjects)) { continue; } ?>
<?php $id = "$fieldname." . ++$idCounter; ?>
<input type="radio" name="<?php echo $fieldname ?>" id="<?php echo $id ?>"
value="<?php echo htmlspecialchars($value) ?>" <?php checkedIf(@$_REQUEST[$fieldname], $value) ?> />
<label for="<?php echo $id ?>"><?php echo htmlspecialchars($label) ?></label><br/>
<?php endforeach ?>
</td>
Hope this helps
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Upload Add Form
By gkornbluth - October 31, 2011 - edited: October 31, 2011
I'm also implementing the UploadAddForm concept for a photo upload application.
My client would like to allow multiple images to be simultaneously selected while browsing, and then all of them uploaded when the form is submitted (the way the flash uploader works).
Any ideas on how to do that?
If I can do that, then the "upload" step can be eliminated and the record will be automatically saved after all the images have been uploaded.
I'd also like to be able to check for missing "required" fields before an upload. Right now the errors only appear after a (possibly very large) image has been uploaded.
I've tried juggling the logic, but the only success I've had is getting the "required field" errors to show up when the form loads initially.
Thanks,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Upload Add Form
By Toledoh - October 31, 2011
Tim (toledoh.com.au)
Re: [Toledoh] Upload Add Form
Looks interesting.
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Upload Add Form
By Codee - November 12, 2012
Re: [Jason] Upload Add Form
By Codee - December 28, 2012
Jerry, did you ever get a response to this question regarding multiple image uploads?