Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
trying to make form that submits both files and text into mysql table
Old 03-21-2009, 02:35 PM trying to make form that submits both files and text into mysql table
Average Talker

Posts: 15
Name: taylor
Trades: 0
form method="post" enctype="multipart/form-data" action="uploadfiles.php" method="POST">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">

<input name="userfile" type="file" id="userfile">
</td>

Case Name: <input type="text" name="cname" action="insertintotable.php" /> <br/>
Author of Case: <input type="text" name="author" action="insertintotable.php" /> <br/>
Business: <input type="text" name="business" action="insertintotable.php"/> <br/>

<td width="80"><input name="uplood" type="submit" class="box" id="uplood" value=" Upload "></td>
</tr>
</table>
</form>

here is my form, i need to put some sort of text field such as

Case Name: <input type="text" name="cname" action="insertintotable.php" /> <br/>

where "insertintotable.php" is my php code that inserts the info



so i want for both actions in "insertintotable.php" and "uploadfiles.php"
to occur by just clicking the submit button.

P.S. im very new to php so i understand i could be going about this the wrong way. if there is a better way to make a form and php code that enters both files and text into a mysql table. please let me know.
antioch1st is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-21-2009, 07:02 PM Re: trying to make form that submits both files and text into mysql table
Novice Talker

Posts: 9
Name: Dan
Trades: 0
Well you can't place an actual file into a mysql table, although you can read the contents of the file and place that into it, or insert a link to the file into the database, have to decide which of those two you'd want to do first.

If you want to put the files contents into it I would use fread() or file_get_contents().
DLaManna is offline
Reply With Quote
View Public Profile
 
Old 03-22-2009, 02:00 AM Re: trying to make form that submits both files and text into mysql table
Average Talker

Posts: 22
Name: adoc fish
Trades: 0
Take a look at http://w3schools.com/tags/tag_input.asp The INPUT tag does not have an ACTION attribute.
_coda_ is offline
Reply With Quote
View Public Profile
 
Old 03-22-2009, 09:03 AM Re: trying to make form that submits both files and text into mysql table
dark_lord's Avatar
Experienced Talker

Posts: 41
Name: Parijat Roy
Location: INDIA-KOLKATA
Trades: 0
@antioch1st

As DlaManna said about placing a link is the more convention way, that will reduce burden on databases, instead of putting the whole file inside database. If you have a powerful database server, then you can use that until and unless the way u r approaching is not recommended.

And as coda said, there is no action attribute in input types.

What you can do is, put both logic of upload.php and insertintotable.php in a single page and then submit the form to that page(say insertupload.php) where you have both upload.php and insertintotable.php logic.

so final form should be like this
Code:
<form method="post" enctype="multipart/form-data" action="insertupload.php">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">

<input name="userfile" type="file" id="userfile">
</td>

Case Name: <input  type="text" name="cname" value="" /> <br/>
Author of Case: <input type="text" name="author" value="" /> <br/>
Business: <input type="text" name="business" value=""/> <br/>

<td width="80"><input name="uplood" type="submit" class="box" id="uplood" value=" Upload "></td>
</tr>
</table>
</form>
__________________
I AM THE BEAUTIFUL NIGHTMARE

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
dark_lord is offline
Reply With Quote
View Public Profile Visit dark_lord's homepage!
 
Old 03-24-2009, 06:23 AM Re: trying to make form that submits both files and text into mysql table
Skilled Talker

Posts: 54
Trades: 0
well my colleagues have said enough just by way of emphasis a text box does not have an action attribute. and also to place a file in a database can be best done by inserting the souce/directory of the file into the database. you can also include a textarea into your form.copy and paste the content of your text file into the text area. this content will be available to the action script in the $_POST or $_GET super global variable when the form is submitted. content will be place into the database by using the INSERT sql query in your action script .
kani alavi is offline
Reply With Quote
View Public Profile
 
Old 04-09-2009, 02:00 PM Re: trying to make form that submits both files and text into mysql table
Average Talker

Posts: 15
Name: taylor
Trades: 0
thanks guys, that worked well
antioch1st is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to trying to make form that submits both files and text into mysql table
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31877 seconds with 12 queries