473,412 Members | 4,519 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Hidden Input Value Not Saving In DB

233 100+
I have an HTML form that includes several input fields and one hidden input field.

Expand|Select|Wrap|Line Numbers
  1. <form name="frm" action="../submit.php" method=get onsubmit="return validate(frm)">
  2.   <table width="350" border="0" cellspacing="0" cellpadding="0" align="center">
  3.     <input type="hidden" name="Type" value="Restaurants" id="Type"/>
  4.     <tr>
  5.     <tr>
  6.       <td class="text"><table width="81%" border="0" cellspacing="6" cellpadding="0">
  7.         <tr>
  8.           <td valign="top" class="text">&nbsp;</td>
  9.           <td valign="top" class="text"><div align="left">Name</div></td>
  10.           <td colspan="3"><div align="left">
  11.             <input type="text" name="Name" cols="45" id="Name">
  12.           </div></td>
  13.         </tr>
  14.         <tr>
  15.           <td valign="top" class="text">&nbsp;</td>
  16.           <td valign="top" class="text"><div align="left">Company</div></td>
  17.           <td colspan="3"><div align="left">
  18.             <input type="text" name="Company" cols="45" id="Company">
  19.           </div></td>
  20.         </tr>
  21.         <tr>
  22.           <td valign="top" class="text">&nbsp;</td>
  23.           <td valign="top" class="text"><div align="left">Address 1</div></td>
  24.           <td colspan="3"><div align="left">
  25.             <input type="text" name="Address1" cols="45" id="Address1">
  26.           </div></td>
  27.         </tr>
  28.         <tr>
  29.           <td valign="top" class="text">&nbsp;</td>
  30.           <td valign="top" class="text"><div align="left">Address 2</div></td>
  31.           <td colspan="3"><div align="left">
  32.             <input type="text" name="Address2" cols="45" id="Address2">
  33.           </div></td>
  34.         </tr>
  35.         <tr>
  36.           <td valign="top" class="text">&nbsp;</td>
  37.           <td valign="top" class="text"><div align="left">City, State, Zip</div></td>
  38.           <td colspan="3"><div align="left">
  39.             <input type="text" name="CityStateZip" cols="45" id="CityStateZip">
  40.           </div></td>
  41.         </tr>
  42.         <tr>
  43.           <td valign="top" class="text">&nbsp;</td>
  44.           <td valign="top" class="text"><div align="left">Phone</div></td>
  45.           <td colspan="3"><div align="left">
  46.             <input type="text" name="Phone" cols="45">
  47.           </div></td>
  48.         </tr>
  49.         <tr>
  50.           <td>&nbsp;</td>
  51.           <td class="text"><div align="left">Email</div></td>
  52.           <td colspan="3"><div align="left">
  53.             <input type="text" name="Email" id="Email"></td>
  54.         </tr>
  55.         <tr>
  56.           <td valign="top" class="text">&nbsp;</td>
  57.           <td valign="top" class="text"><div align="left">Quantity<br>
  58.             Requested/<br>
  59.             Other<br>
  60.             Comments</div></td>
  61.           <td colspan="3"><div align="left">
  62.             <textarea name="Comments" cols="15" rows="5"></textarea></td>
  63.         </tr>
  64.         <tr>
  65.           <td>&nbsp;</td>
  66.           <td>&nbsp;</td>
  67.         </tr>
  68.         <tr>
  69.           <td>&nbsp;</td>
  70.           <td>&nbsp;</td>
  71.           <td><input type="submit" name="Submit" value="Submit">
  72.             <input type="reset" name="Clear" value="Clear" id="Clear"></td>
  73.         </tr>
  74.       </table></td>
  75.     </tr>
  76.     <tr>
  77.       <td>&nbsp;</td>
  78.     </tr>
  79.   </table>
  80. </form>
When I go to insert the input values from within submit.php, all of the input fields save correctly except for the hidden input field. From submit.php:

Expand|Select|Wrap|Line Numbers
  1. if(isset($_POST['action']) && $_POST['action'] == 'submitform')
  2. {
  3.     //recieve the variables
  4.  
  5.     $Name = $_POST['Name']; //referrername field posted to referrername column in the db
  6.     $Company = $_POST['Company'];
  7.     $Address1 = $_POST['Address1'];
  8.     $Address2 = $_POST['Address2'];
  9.     $CityStateZip = $_POST['CityStateZip'];
  10.     $Phone = $_POST['Phone'];
  11.     $Email = $_POST['Email'];
  12.     $Comments = $_POST['Comments'];
  13.     $type = $_POST['Type'];
  14. }
  15.  
  16. $phone = remove_non_numeric($phone);
  17. //save the data on the DB
  18.  
  19. mysql_select_db($database, $connection);
  20.  
  21. //insert query would need to be updated to match column names in the db, the number of values would need to correspond to the number of fields
  22. $insert_query = sprintf("INSERT INTO storypac (Name, Company, Address1, Address2, CityStateZip, Phone, Email, Comments, type) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
  23.                         sanitize($Name, "text"),
  24.                         sanitize($Company, "text"),
  25.                         sanitize($Address1, "text"),
  26.                         sanitize($Address2, "text"),
  27.                         sanitize($CityStateZip, "text"),
  28.                         sanitize($Phone, "text"),
  29.                         sanitize($Email, "text"),
  30.                         sanitize($Comments, "text"),
  31.                         sanitize($type, "text"));
  32.  
  33. $result = mysql_query($insert_query, $connection) or die(mysql_error());
I cannot seem to figure out why the value of the hidden field 'Type' is not saved in the database. As for the data types of the columns in the DB, all are varchar(32-64). Any help would be appreciated.
Jul 15 '11 #1
1 2235
johny10151981
1,059 1GB
Your database field type is char not integer
Jul 16 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: pablo | last post by:
Dear News Groupers, I'am trying to send a php array with a hidden input field from a form to another script. The array is NOT made directly by way of <input name="arrayname" />. The array is...
6
by: Dan | last post by:
Is there a way to access and set a hidden input types in the code-behind page for ASP.Net? This seems like a common thing that would need to be done, I must be missing something obvious. ...
1
by: Rob Meade | last post by:
Hi all, I have a loop in my code which builds the controls on the page. I at one stage need to add some hidden input controls dynamically, I have achieved this, and I have set their...
4
by: Alex | last post by:
Is there any way to delete the value of a html hidden input field from code-behind? I use an html hidden input to store an array of data. I collect this data using Request.Form or Request.Params....
2
by: Navillus | last post by:
Hi all, I'm trying to insert a javascript variable into a hidden input form field. Here's what it looks like: <form name="loginForm" action="scripts/wgate/ziac_login/!?~language=EN"> <input...
4
by: WB | last post by:
Hi, I need to validate a hidden input in my webform to ensure that it's got value. The controls look something like this: <input id="HidSelectedStates" type="hidden" runat="server" /><br...
17
by: SimonWilding | last post by:
I am using a line of javascript that both sets the value of a hidden input element (name='button') and then submits the form. The destination of the post can then pick up the value of the hidden...
4
by: Bosconian | last post by:
I've been fighting with this for an hour. My form contains a hidden input with the value initially set to "". When a user clicks on the link, a function is called that updates the hidden form...
2
by: corykendall | last post by:
Here is my code: ... Setting hidden input to: <dsp:valueof param="tabname"/> <input name="tabname" type="hidden" value='<dsp:valueof param="tabname"/>'/> </dsp:form> hidden input set...
3
by: zac540 | last post by:
Hey everyone! First of all I'd like to say that I did my best to look for any other relevant posts. The best I found was this interesting thread.. http://bytes.com/forum/thread594982.html If...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.