473,698 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

automatic save

underscore
30 New Member
gud day to all TSD.


if i run the code below which is HTML combine with php. my problem encoutered in php code. it will automatically save all blank textbox i declare in php to my database using mysql if i will run this page.

please correct my problem in my code.

thnx again...

Expand|Select|Wrap|Line Numbers
  1.  
  2. <? session_start(); ?>
  3.  
  4. <head>
  5. <title>My Page</title>
  6. <style type="text/css">
  7. <!--
  8. #Layer1 {
  9. position:absolute;
  10. left:200px;
  11. top:10px;
  12. width:816px;
  13. height:540px;
  14. z-index:1;
  15. }
  16. .style3 {font-family: Arial, Helvetica, sans-serif}
  17. .style4 {font-family: Arial}
  18. a:link {
  19. text-decoration: none;
  20. }
  21. a:visited {
  22. text-decoration: none;
  23. }
  24. a:hover {
  25. text-decoration: none;
  26. }
  27. a:active {
  28. text-decoration: none;
  29. }
  30. .style14 {color: #FF0000; font-family: Geneva, Arial, Helvetica, sans-serif; }
  31. -->
  32. </style>
  33. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  34. </head>
  35.  
  36. <body>
  37.  
  38. <div id="Layer1">
  39. <table width="808" height="538" border="0" cellpadding="0" cellspacing="0" bordercolor="#2A1F00">
  40. <tr>
  41. <td width="236" height="110"><img src="image/Nagano Header.jpg" width="236" height="110" alt="" /></td>
  42. <td colspan="4"><img src="image/header.jpg" width="598" height="110" alt="" /></td>
  43. </tr>
  44. <tr>
  45. <td height="22" colspan="5" bordercolor="#0000FF" bgcolor="#DAE2C7"><span class="style14">CREATE YOUR ID</span> </td>
  46. </tr>
  47.  
  48. <form name="form1" method="post" action="register.php">
  49.  
  50. <tr>
  51. <td height="42" bgcolor="#F7F7F7"><div align="right" class="style3">* First Name </div></td>
  52. <td width="20" bgcolor="#F7F7F7">&nbsp;</td>
  53. <td width="159" bgcolor="#F7F7F7"><input name="txtfname" type="text" id="txtfname" /></td>
  54. <td width="48" bgcolor="#F7F7F7">&nbsp;</td>
  55. <td width="364" bgcolor="#F7F7F7"><label></label></td>
  56. </tr>
  57. <tr>
  58. <td height="25" bordercolor="#F7F3EF" bgcolor="#F7F7F7"><div align="right">* <span class="style4">Last Name</span> </div></td>
  59. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7">&nbsp;</td>
  60. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7"><input name="txtlname" type="text" id="txtlname" /></td>
  61. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7">&nbsp;</td>
  62. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7"><label></label></td>
  63. </tr>
  64. <tr>
  65. <td height="36" bordercolor="#F7F3EF" bgcolor="#F7f7f7"><div align="right" class="style4">* Gender </div></td>
  66. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7">&nbsp;</td>
  67. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7"><select name="mnugender" id="mnugender">
  68. <option value="0">[Select]</option>
  69. <option value="1">Male</option>
  70. <option value="2">Female</option>
  71. </select></td>
  72. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7">&nbsp;</td>
  73. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7"><label></label></td>
  74. </tr>
  75. <tr>
  76. <td height="34" bordercolor="#F7F3EF" bgcolor="#F7F7F7"><div align="right">* Log-in ID </div></td>
  77. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7">&nbsp;</td>
  78. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7"><label>
  79. <input name="txtlogid" type="text" id="txtlogid">
  80. </label></td>
  81. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7">&nbsp;</td>
  82. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7">&nbsp;</td>
  83. </tr>
  84. <tr>
  85. <td height="34" bordercolor="#F7F3EF" bgcolor="#F7F7F7"><div align="right" class="style4">* Password</div></td>
  86. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7">&nbsp;</td>
  87. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7"><input name="txtpassword" type="password" id="txtpassword" /></td>
  88. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7">&nbsp;</td>
  89. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7">&nbsp;</td>
  90. </tr>
  91.  
  92. <tr>
  93. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7"><div align="right" class="style4">* Re-type Password </div></td>
  94. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7">&nbsp;</td>
  95. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7"><input name="txtretypepass" type="password" id="txtretypepass" /></td>
  96. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7">&nbsp;</td>
  97. <td bordercolor="#F7F3EF" bgcolor="#F7F7F7"><label></label></td>
  98. </tr>
  99. <tr>
  100. <td height="38" bgcolor="#F7F7F7"><div align="right"><span class="style4">Birth Date </span></div></td>
  101. <td bgcolor="#F7F7F7">&nbsp;</td>
  102. <td bgcolor="#F7F7F7"><select name="mnuMonth" id="mnuMonth">
  103. <option value="0">[Select Month]</option>
  104. <option value="1">January</option>
  105. <option value="2">February</option>
  106. <option value="3">March</option>
  107. <option value="4">April</option>
  108. <option value="5">May</option>
  109. // OTHER OPTION VALUES 6-11 GOES HERE
  110. <option value="12">December</option>
  111. </select></td>
  112. <td bgcolor="#F7F7F7"><label>
  113. <select name="txtday" id="txtday">
  114. <option value="1" selected>1</option>
  115. <option value="2">2</option>
  116. <option value="3">3</option>
  117. // OTHER OPTION VALUES 3-30 GOES HERE
  118. <option value="31">31</option>
  119. </select>
  120. </label></td>
  121. <td bgcolor="#F7F7F7"><label>
  122. <input name="txtyear" type="text" id="txtyear" value="yyyy" size="4">
  123. </label></td>
  124. </tr>
  125. <tr>
  126. <td height="39" bgcolor="#F7F7F7"><div align="right" class="style4">Zip/Postal code </div></td>
  127. <td bgcolor="#F7F7F7">&nbsp;</td>
  128. <td bgcolor="#F7F7F7"><input name="txtzip" type="text" id="txtzip" /></td>
  129. <td bgcolor="#F7F7F7">&nbsp;</td>
  130. <td bgcolor="#F7F7F7">&nbsp;</td>
  131. </tr>
  132. <tr>
  133. <td height="27" bgcolor="#F7F7F7"><div align="right"><span class="style4">* Email Address</span></div></td>
  134. <td bgcolor="#F7F7F7">&nbsp;</td>
  135. <td bgcolor="#F7F7F7"><input name="txtemailadd" type="text" id="txtemailadd" /></td>
  136. <td bgcolor="#F7F7F7">&nbsp;</td>
  137. <td bgcolor="#F7F7F7">&nbsp;</td>
  138. </tr>
  139.  
  140. <tr>
  141. <td height="33" bgcolor="#F7F7F7"><div align="right" class="style4">User Access Level </div></td>
  142. <td bgcolor="#F7F7F7">&nbsp;</td>
  143. <td bgcolor="#F7F7F7"><label>
  144. <select name="mnuAccess" id="mnuAccess">
  145. <option value="0">[Select Level]</option>
  146. <option value="1">Administrator</option>
  147. <option value="2">Limited</option>
  148. </select>
  149. </label></td>
  150. <td bgcolor="#F7F7F7">&nbsp;</td>
  151. <td bgcolor="#F7F7F7">&nbsp;</td>
  152. </tr>
  153. <tr>
  154. <td height="19" bgcolor="#F7F7F7">&nbsp;</td>
  155. <td bgcolor="#F7F7F7">&nbsp;</td>
  156. <td bgcolor="#F7F7F7"><label></label></td>
  157. <td bgcolor="#F7F7F7">&nbsp;</td>
  158. <td bgcolor="#F7F7F7">&nbsp;</td>
  159. </tr>
  160. <tr>
  161. <td bgcolor="#F7F7F7"><a href="index.html" target="_parent"></a></td>
  162. <td bgcolor="#F7F7F7">&nbsp;</td>
  163. <td bgcolor="#F7F7F7"><input name="Submit" type="Submit" class="style4" id="Submit" value=" Submit " onClick="javascript:alert('Your form has been submitted')">
  164. <td bgcolor="#F7F7F7">&nbsp;</td>
  165. <td bgcolor="#F7F7F7">&nbsp;</td>
  166. </tr>
  167.  
  168. <tr>
  169. <td height="24" colspan="5" bgcolor="#F7F7F7"><div align="left">
  170. <blockquote>
  171. <blockquote>
  172. <blockquote>
  173. <blockquote>
  174. <blockquote>
  175. <blockquote>
  176. <p><a href="index.html" target="_parent"><strong>BACK TO HOME PAGE </strong></a></p>
  177. </blockquote>
  178. </blockquote>
  179. </blockquote>
  180. </blockquote>
  181. </blockquote>
  182. </blockquote>
  183. </div></td>
  184. </tr>
  185. <tr>
  186. <td bgcolor="#F7F7F7"><div align="right" class="style4"><a href="index.html" target="_parent"></a></div></td>
  187. <td bgcolor="#F7F7F7">&nbsp;</td>
  188. <td bgcolor="#F7F7F7"><a href="index.html" target="_parent"></a></td>
  189. <td bgcolor="#F7F7F7">&nbsp;</td>
  190. <td bgcolor="#F7F7F7"><label></label></td>
  191. </tr>
  192. </table>
  193.  
  194. </div>
  195. </body>
  196. </html>
  197.  
  198. <?php
  199.  
  200. if (isset($_POST["Submit"]))
  201.  
  202. include'package/connect.inc.php';
  203. mysql_select_db('database');
  204.  
  205. $user_sql = "INSERT INTO userpass(loginId,fname,lname,gender,password,repassword,bdate,zip,emailadd,accesslevel,regdate,reghours)
  206. values('". $_POST["txtlogid"] ."','". $_POST["txtfname"] ."','". $_POST["txtlname"] ."',
  207. '". $_POST["mnugender"] ."','". $_POST["txtpassword"] ."',
  208. '". $_POST["txtretypepass"]."','". $_POST["mnuMonth"]."-". $_POST["txtday"]."-". $_POST["txtyear"]."',
  209. '". $_POST["txtzip"]."',
  210. '". $_POST["txtemailadd"]."','". $_POST["mnuAccess"]."',
  211. '". date("F j, Y, g:i a")."','". date("H:i:s A")."')";
  212. $result = mysql_query($user_sql);
  213.  
  214. }
  215. ?>
  216.  
Sep 18 '07
13 2654
underscore
30 New Member
Well you do have an if statement that controls nothing [PHP]if (isset($_POST["Submit"]))

include'package/connect.inc.php ';
mysql_select_db ('database');[/PHP]Looks like you are missing a brace after the if statement
ok in my code that is pair ( { } ) in if statement. but the same it will automatically save.
Sep 20 '07 #11
code green
1,726 Recognized Expert Top Contributor
ok in my code that is pair ( { } ) in if statement. but the same it will automatically save.
If the $_POST["Submit"] button has been clicked you will write to the database.
If you are writing to the database without clicking then your php code is wrong.
Can you show the true version (please leave out the HTML)
Sep 20 '07 #12
underscore
30 New Member
If the $_POST["Submit"] button has been clicked you will write to the database.
If you are writing to the database without clicking then your php code is wrong.
Can you show the true version (please leave out the HTML)
this is the php code:

<?php

if (isset($_POST["Submit"]))
{
include'package/connect.inc.php ';
mysql_select_db ('database');

$user_sql = "INSERT INTO userpass(loginI d,fname,lname,g ender,password, repassword,bdat e,zip,emailadd, accesslevel,reg date,reghours)
values('". $_POST["txtlogid"] ."','". $_POST["txtfname"] ."','". $_POST["txtlname"] ."',
'". $_POST["mnugender"] ."','". $_POST["txtpasswor d"] ."',
'". $_POST["txtretypep ass"]."','". $_POST["mnuMonth"]."-". $_POST["txtday"]."-". $_POST["txtyear"]."',
'". $_POST["txtzip"]."',
'". $_POST["txtemailad d"]."','". $_POST["mnuAccess"]."',
'". date("F j, Y, g:i a")."','". date("H:i:s A")."')";
$result = mysql_query($us er_sql);

}
?>
Sep 21 '07 #13
code green
1,726 Recognized Expert Top Contributor
ok sir. my problem is if i run those PHP code it will automatically save to mysql database. in the PHP at the buttom
If below is the correct opening of the php code
[PHP]if (isset($_POST["Submit"]))
{[/PHP]And this is the correct HTML for the submit button
[HTML]"><input name="Submit" type="Submit" [/HTML]
Then what we seem to be missing now is a closing form tag [HTML]</form>[/HTML]
Sep 21 '07 #14

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

Similar topics

2
4474
by: Chris Lobdell | last post by:
Hey, everyone. For the past two years, we have offered files for download through a secure website. Users, after clicking on a link, are redirected to a PHP page that passes the appropriate header information to the user and inquires if that user wishes to download the file. A sample of that code is below: header('Content-Type: application/save'); header('Content-Disposition:attachment; filename="'.$file_path .'"');
3
1757
by: Ido | last post by:
Hello, I am searching for an automatic forms creation tool that will help me to save time in developin forms (preferrably with validation). My forms get some data from a MySQL database and are supposed to save all data back to the database. Any recommendations!?
19
4013
by: Mel | last post by:
when downloading files from my site, when file types are known (i.e *.doc) browsers open the file for viewing. is there a way to disable that and just present the save as dialog (same as for unknown types zip files etc.) ? thanks Mel
1
2230
by: Federico | last post by:
I want to create an automatic log system that writes to a ofstream (the logfile) all the output sent to screen. I tried to make a class COutput with the operator << overloaded for the different kind of data types, but a problem arrived when I tried to use io manipulators such as setprecision. I have this in class COutput: COutput& operator<<(ios& (*fnc)(ios&)) { (*fnc)(cout); // For the screen (*fnc)(logfile); // For the logfile (an...
2
2123
by: ray | last post by:
I have a client that doesn't want Access to automatically repair into a backup file if it crashes (and it crashes only on very rare occasions). My (sketchy) understanding is that this is a Windows function that can't be stopped by using runtime switches, advanced options or other hi-falutin' database properties. Ami I correct that the automatic repair has nothing to do with Access itself? Is there another way to stop it happening?
6
2025
by: Mike Saunders | last post by:
I have a basic web site where people can download my programs. To make it easier for them is it possible that I could add some javascript that would allow them to automatically install/run the program for them maybe with appropriate options/warnings etc Sme example code would be most appreciated Many thanks
58
4654
by: Jorge Peixoto de Morais Neto | last post by:
I was reading the code of FFmpeg and it seems that they use malloc just too much. The problems and dangers of malloc are widely known. Malloc also has some overhead (although I don't know what is the overhead of automatic variable sized arrays, I suspect it is smaller than that of malloc), although I'm not too worried about it. I was thinking that, with C99's variable length arrays, malloc shouldn't be needed most of the time. But I'm...
6
3229
by: subhashkumar | last post by:
Running data Append to a table Dear All, I need a help from this forum, I was developing a small tools for stock market. I get stuck when trying to save the running changes in a data field value from a form to a table. Here I have two table and one form 1. LiveData - (Connected to external file which reflect the changes automaticaly)
3
4641
by: Peter Hofmann | last post by:
When I change the source code and save it I have currently always to press explicitely F6 zu "compile" the code (and get new error list). Isn't there an automatic build function which is called whenever I save new code ? BTW: What is the difference between the two menues: Build->Build solution and
1
2937
by: TechieGrl | last post by:
I want to save a zip file daily. The file is named the same thing each day so I would like to create a folder and name it with today's date and then save the zip file into that folder. I'm using this code and can't seem to figure out how to create the new folder and save the file there. Any help is appreciated! $todays_date = date("Ymd");
0
8676
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9161
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8867
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6522
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.