Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old April 18th, 2004, 08:55 PM
sbash sbash is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 11 sbash User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
checkbox and file values in forms

I'm reasonably confident this is an html issue not a php issue, but I could be wrong. If it is an html problem, this is what it is:

When I send data from two forms, a text area and a series of checkboxes, to a new page, I can access the values of both through $_POST[] in php. I then submit the text area contents to each database that was selected in the check boxes.

When I try to do exactly the same thing with a form that selects and sends a file and a form that has series of checkboxes, the check boxes' values are never set. This is what works

<form action="811updateeng.php" method="POST"/>
<textarea name= "hwtext" rows="10" cols="50" wrap>
</textarea><br /><br />
<input type="submit" value"GO">

<form name="form1" method="post" action="811updateeng.php">
811 <input type="checkbox" name="811" value="checkbox">
813 <input type="checkbox" name="813" value="checkbox">
</form>

This is what doesn't work:

<form name="form2" method="POST" action="myupload.php">
811 <input type="checkbox" name="811" value="checkbox">
813 <input type="checkbox" name="813" value="checkbox">
</form>

<form enctype="multipart/form-data" action="myupload.php" method="post">
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>

I've futzed around with this, but can't make it work. I'm figuring that the file type is somehow unsetting the value of my checkboxes??? I really have no idea, and appreciate any advice.

Reply With Quote
  #2  
Old April 19th, 2004, 12:11 AM
CodeKadiya CodeKadiya is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,313 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Send a message via Yahoo to CodeKadiya
RE: checkbox and file values in forms

You can't get the selected file using $_POST[] superglobal. You got to have $_FILES[]... that could be the problem.

Reply With Quote
  #3  
Old April 19th, 2004, 01:09 AM
sbash sbash is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 11 sbash User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: checkbox and file values in forms

thanks

I guess I wasn't clear. I have no problem uploading and moving the file. The problem is that when I do, the value of the checkboxes is lost. This what I'm doing:
php Code:
Original - php Code
  1.  
  2. if (move_uploaded_file($_FILES['userfile']['tmp_name'], 'uploads/'.$_FILES ['userfile']['name'])) {
  3. echo "copy made";
  4. }
  5.  
  6. $link = $_FILES['userfile']['name'];
  7. require_once("teacherconnect.php");
  8. $enter = "INSERT INTO 811eng (assignment) VALUES ('download this worksheet:<a href="/uploads/$link"> $link</a>')";
  9.     $query = mysql_query($enter);
  10.     if (!$query) {
  11.     echo("<p>your assignment for 811 did not load in the database</p>");   
  12.     exit();
  13.                             } 



That all works fine. What I want to do is put the mysql_query inside an if a statement like so

php Code:
Original - php Code
  1. if (isset($_POST['811'])) {  database insert } 


what happens is that the post variable from the checkbox is never set. I am wondering if that problem is in some way related to the fact that I'm sending a file rather than the value of a text area, because I follow a method I use with a text area successfully.

Reply With Quote
  #4  
Old April 19th, 2004, 04:42 AM
sbash sbash is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 11 sbash User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: checkbox and file values in forms

a closing curly brace inside a comment was the problem all along. the form stuff works fine

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > checkbox and file values in forms


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway