473,404 Members | 2,137 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,404 software developers and data experts.

automatic save

underscore
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 #1
13 2629
ak1dnar
1,584 Expert 1GB
I had to remove some Html contents from the above code, because forum software doesn't support for that much of lines of code tags on a single attempt.
And I've added some comments on the removed sections and the
[code=php] tags too to the code listening. Thanks a lot.
Sep 18 '07 #2
I had to remove some Html contents from the above code, because forum software doesn't support for that much of lines of code tags on a single attempt.
And I've added some comments on the removed sections and the
[code=php] tags too to the code listening. Thanks a lot.

the result mr .jax still d same when i run this page it will automatically save a blank in my database.?

thnx
Sep 18 '07 #3
code green
1,726 Expert 1GB
the result mr .jax still d same when i run this page it will automatically save a blank in my database.?
NO! ajaxrand did not try to help you, he tried to help the rest of us by removing chunks of code not relevant to the problem.
There is still far too much code.
What is the problem and where is it occuring?
Sep 18 '07 #4
ak1dnar
1,584 Expert 1GB
@underscore

Is this mysql_query() is running when you loading the page for the very first time?

@code green
Please don't use "Alaxrand" again, Its too ugly. ;)
Sep 18 '07 #5
code green
1,726 Expert 1GB
Ajaxrand - Sorry slip of the fingers. 'l' and 'j' are only two keys apart.
underscore - You can get around this problem by employing basic techniques that should always be used.
I am referring to verifying POST data, especially before inserting into a database.
If you had placed these checks in the script it would help you greatly towards identifying the underlying problem,
which I still can't see by the way.
Sep 18 '07 #6
ak1dnar
1,584 Expert 1GB
First turn on the Error reporting. There are some instruction how to do that on the top of the php forum home page.
Why I am saying this, I didn't see the the opening "{" bracket for the "if" condition but closing bracket is there as the last line.
Sep 18 '07 #7
@underscore

Is this mysql_query() is running when you loading the page for the very first time?

@code green
Please don't use "Alaxrand" again, Its too ugly. ;)

yes sir! when i run the page the mysql was already runing. is thr wrong with it?
Sep 20 '07 #8
NO! ajaxrand did not try to help you, he tried to help the rest of us by removing chunks of code not relevant to the problem.
There is still far too much code.
What is the problem and where is it occuring?
ok sir. my problem is if i run those PHP code it will automatically save to mysql database. in the PHP at the buttom.
Sep 20 '07 #9
code green
1,726 Expert 1GB
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
Sep 20 '07 #10
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 Expert 1GB
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
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(loginId,fname,lname,gender,password,repas sword,bdate,zip,emailadd,accesslevel,regdate,regho urs)
values('". $_POST["txtlogid"] ."','". $_POST["txtfname"] ."','". $_POST["txtlname"] ."',
'". $_POST["mnugender"] ."','". $_POST["txtpassword"] ."',
'". $_POST["txtretypepass"]."','". $_POST["mnuMonth"]."-". $_POST["txtday"]."-". $_POST["txtyear"]."',
'". $_POST["txtzip"]."',
'". $_POST["txtemailadd"]."','". $_POST["mnuAccess"]."',
'". date("F j, Y, g:i a")."','". date("H:i:s A")."')";
$result = mysql_query($user_sql);

}
?>
Sep 21 '07 #13
code green
1,726 Expert 1GB
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
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...
3
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...
19
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...
1
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...
2
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...
6
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...
58
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...
6
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...
3
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.