473,789 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

updating table using a form

25 New Member
I am trying to submit entries in a form to a database. I am using
[code[
action="$_SERVE R[PHP_SELF]"
[/code]
within my submission form and
Expand|Select|Wrap|Line Numbers
  1. $_POST['value-to-be-submitted']
  2.  
I am getting the connection to the database but I my script is not executing, probably due to a syntax error which I can't see.

here is the code, first the submission page, then the php script

submission page
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <? include("http://localhost/Project/customers.php") ?>
  3. <HTML>
  4.  <HEAD>
  5.   <TITLE> ALLIED AUTO PARTS </TITLE>
  6.   <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
  7.   <META NAME="Generator" CONTENT="EditPlus">
  8.   <META NAME="Author" CONTENT="">
  9.   <META NAME="Keywords" CONTENT="">
  10. <script type="text/javascript" language="javascript">
  11. var poststr = "?";
  12. function addCustomer()
  13.     { 
  14.     var url="http://localhost/Project/addCustomer.php";
  15.     if(window.XMLHttpRequest)
  16.     http = new XMLHttpRequest(); 
  17.     else if (window.ActiveXObject)
  18.     http  = new ActiveXObject(Microsoft.XMLHTTP); 
  19.     http.onreadystatechange = function()
  20.         { 
  21.         alert(http.readyState);
  22.         if(http.readyState == 4)
  23.             {
  24.             alert(http.status)
  25.             if(http.status == 200)
  26.                 {
  27.                 response = http.responseText;
  28.                 alert(response);
  29.                 }    
  30.             else    
  31.                 {
  32.                 alert(http.status);
  33.                 }    
  34.             } 
  35.         }
  36.         http.open("POST", url + poststr, true); 
  37.         http.setRequestHeader("text"); 
  38.         http.send(null); 
  39.     }
  40.  
  41. function reset()
  42.     {
  43.         document.updateCustomer.customer_name.value = "";
  44.         document.updateCustomer.customer_address.value = "";
  45.         document.updateCustomer.customer_contact_no.value = "";
  46.     }
  47.  
  48. function get(obj)
  49.     {
  50.     if((document.updateCustomer.customer_name.value == "") || (document.updateCustomer.customer_address.value == "") || (document.updateCustomer.customer_contact_no.value == ""))
  51.         {
  52.         alert("One or more fields are missing");
  53.         }
  54.         else
  55.             {
  56.             alert("ok");
  57.             poststr += "document.updateCustomer.customer_name.value" + "&document.updateCustomer.customer_address.value" + "&document.updateCustomer.customer_address.value";
  58.             }
  59.             addCustomer();
  60.     }
  61. </script>
  62.  
  63.   </HEAD>
  64.     <BODY onload="reset();">
  65. <p align="center">
  66. To add a new customer fill in the new customers name, address and contact number, then click <b>addCustomer</b>.
  67. <p align="center">
  68. To delete an existing customer, fill in the the details form the customers listed above, then click <b>deleteCustomer</b>.
  69. <p>
  70. <table border="1" align="center">
  71. <tr>
  72. <td align="center">Customer Name</td>
  73. <td><input type="hidden" size="10"/></td>
  74. <td align="center">Customer Address</td>
  75. <td><input type="hidden" size="10"/></td>
  76. <td align="center">Customer Contact Number</td>
  77. </tr>
  78. <tr>
  79. <form name="updateCustomer" method="POST" action="$_SERVER['PHP_SELF']">
  80. <td align="center"><input type="text" name="customer_name" id="customer_name" size="25" value=""/></td>
  81. <td><input type="hidden" size="10"/></td>
  82. <td align="center"><input type="text" name="customer_address" id="customer_address" size="25" value=""/></td>
  83. <td><input type="hidden" size="10"/></td>
  84. <td align="center"><input type="text" name="customer_contact_no" id="customer_contact_no" size="12" value=""/></td>
  85. <td><input type="hidden" size="10"/></td>
  86. <td align="center"><input type="button" name="addCustomer" value="addCustomer" onclick="get(this);"/></td>
  87. <td><input type="hidden" size="10"/></td>
  88. <td align="center"><input type="button" name="deleteCustomer" value="deleteCustomer" onclick="deleteCustomer();"/></td>
  89. </form>
  90. </tr>
  91. </table>
  92. </p>
  93. <H1 align="center">ALLIED AUTO PARTS</H1>
  94. <p>
  95. <TABLE align="center">
  96. <TR>
  97.     <TD align="center" colspan="6"><H3>Choose from the following funtions</H3></TD>
  98. </TR>
  99. <TR>
  100.     <TD><a href="ViewParts.php">View Parts</a></TD>
  101.     <TD><a href="Purchases.php">Purchases</a></TD>
  102.     <TD><a href="Sales.php">Sales</a></TD>
  103.     <TD><a href="UpdateParts.php">Add parts</a></TD>
  104.     <TD><a href="UpdateCustomer.php">Update Customer</a></TD>
  105.     <TD><a href="UpdateSupplier.php">Update Supplier</a></TD>
  106. </TR>
  107. </TABLE>
  108.  

php script
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. $connect=pg_connect("dbname=AlliedAutoParts host=localhost user=User password=password");
  3. if (!pg_connection_busy($connect))
  4.     {
  5.     $result=pg_query($connect, "insert into customer values($_POST['customer_name'], $_POST['customer_address'], $_POST['customer_contact_no'])");
  6.     }
  7.     echo "New customer added";
  8. ?>
  9.  
Using alerts to debug I am getting OK,1, 2, 3, 4, 200, "blank alert".

rpjd
Apr 28 '07 #1
2 1773
devsusen
136 New Member
Hi,

please put this line for getting the error, it will be easier if u r getting the error printed in ur page.

[PHP]ini_set('displa y_errors', '1');[/PHP]

please let us know whats the error u r getting.

susen
Apr 28 '07 #2
rpjd
25 New Member
Hi,

please put this line for getting the error, it will be easier if u r getting the error printed in ur page.

[PHP]ini_set('displa y_errors', '1');[/PHP]

please let us know whats the error u r getting.

susen
I seemed to have solved the error here
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. $connect=pg_connect("dbname=AlliedAutoParts host=localhost user=User password=password");
  3. if (!pg_connection_busy($connect))
  4.     {
  5.     $result=pg_query($connect, "insert into customer values('$customer_name', '$customer_address', '$customer_contact_no')");
  6.     }
  7.     echo "New customer added";
  8. ?>
  9.  
Apr 28 '07 #3

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

Similar topics

3
2958
by: | last post by:
Hello, Sorry to ask what is probably a simple answer, but I am having problems updating a table/database from a PHP/ PHTML file. I can Read From the Table, I can Insert into Table/Database, But not update. Here is a copy of the script I am using. I do not know what version of MySQL my host is running nor do I have Shell Access to it. I
11
16229
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? 1) simply UPDATING the values for all fields in the table, whether or not any particular field has actually changed 2) running a second SELECT statement and comparing the $_POST vars to the returned values, and only UPDATING those that have...
2
2408
by: Ray Holtz | last post by:
I have a form that shows a single record based on a query criteria. When I click a button it is set to use an append query to copy that record to a separate table, then deletes the record from the first table. Both tables have a 'DateTime' field that shows when it was last updated using the Now function. What I am trying to do is get the 'DateTime' field updated after the append query copies it to the new table. I have tried updating...
1
2292
by: chrisc | last post by:
Hello, Im using redemption in a database created in ms access. At the moment emails are generated depending on various actions within a database. To give an example: Public Const Email_StencilOrderer = "CA" 'Joe Bloggs Then later on when an action is taken I will call this like so:
10
5686
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1) DsStudentCourse1.AcceptChanges() i'm also wondering because w/ out AcceptChanges the data is still save into the database and it is now faster.
33
3354
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range of 20 steps) On the admin page the steps are listed, in "order" order and the user can create new steps and assign an order and all is well. The problem may come in using a renumber function which should take the steps in their current order...
6
3683
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
3
1797
by: Spoogledrummer | last post by:
Hi it's me again, still working on the sam 5 minute problem so feeling kind of thick now. I've dumped the idea of using a textarea for now and am using a textbox instead but am struggling when it comes to updating the database, I've tried several different methods and the one I'm currently battling with is as follows: % set objconn=server.CreateObject("ADODB.connection") objconn.Mode=3 objconn.Open ("DSN=localserver; User ID=blah;...
5
7471
stepterr
by: stepterr | last post by:
I have a form that is built based on a query. Everything is working except when I submit the form the radio buttons are only updating the first row in my database. dcategory and dthumbnail are two radio buttons that I have for each one of the rows in the table. I've tried using a hidden input object for each of the radio button groups to store the values in but clearly I'm having a mental block because I can't get that to work right either. So...
2
3322
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi All! I am with a situation where I am not getting the right updating to the form's fields. The situation is the following one: I have one combobox and one textbox. I am using the CurrentChanged event of the BindingSource of the combobox to update the textbox. When selecting an item in the combobox or when selecting a row in the grid, it is updating the textbox correctly. The problem is when I apply a filter in the grid, and then...
0
9666
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
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10200
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7529
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
6769
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
5422
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...
1
4093
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
2
3703
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
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.