I am trying to code a page that allows the user to edit the content that is drawn from the database. The fields show the correct data from the database, and you can type in the fields, but the database does not update when the "submit" button is clicked. It jumps to the events list page, as it should, but the information has not been changed.
My code is as follows:
Top of page
[php]
<? if (array_key_exis ts('_submit_che ck', $_POST)) {
mysql_query("UP DATE events SET eventTitle = '$eventTitle', eventInfo = '$eventInfo', eventImage = '$eventImage' WHERE eventID = '$id'");
header("Locatio n: eventsList.php" );
}
?>[/php]
Within the template
[php]<?php
mysql_select_db ($database_Site , $Site);
$query = "SELECT * FROM events WHERE eventID = '$id'";
$result = mysql_query($qu ery) or die ("Error in query: $query. " . mysql_error());
$id = mysql_result($r esult,$i,"event ID");
$eventTitle = mysql_result($r esult,$i,"event Title");
$eventInfo = mysql_result($r esult,$i,"event Info");
$eventImage = mysql_result($r esult,$i,"event Image");
?>
<form action="<? echo $PHP_SELF; ?>" method="POST">
<input type="hidden" name="_submit_c heck" value="1"/>
<input type="hidden" name="eventID" value="<? echo $id; ?>">
<tr>
<td valign="top"><b ><font size="2" face="Arial, Helvetica, sans-serif">Title</font></b></td>
<td><input size="50" maxlength="250" type="text" name="eventTitl e" value="<? echo $eventTitle; ?>">
</td>
</tr>
<tr>
<td valign="top"><b ><font size="2" face="Arial, Helvetica, sans-serif">Informat ion</font></b></td>
<td><textarea name="eventInfo " cols="40" rows="10"><? echo $eventInfo; ?></textarea>
</td>
</tr>
<tr>
<td valign="top" align="left"><f ont face="Arial, Helvetica, sans-serif" size="2"><b>Ima ge</b></font></td>
<td><input size="50" maxlength="250" type="text" name="eventImag e" value="<? echo $eventImage; ?>">
</td>
</tr>
<tr align="center" valign="top">
<td colspan=2><inpu t type="Submit" name="submit" value="Update">
</td>
</tr>
</form>[/php]
Any help would be appreciated.
1 1523 mwasif 802
Recognized Expert Contributor
Hi lilbadger25,
Welcome to TSDN!!!
[php]
<? if (array_key_exis ts('_submit_che ck', $_POST)) {
mysql_query("UP DATE events SET eventTitle = '$eventTitle', eventInfo = '$eventInfo', eventImage = '$eventImage' WHERE eventID = '$id'");
header("Locatio n: eventsList.php" );
}
?>[/php]
What is the value of $id and where you are assigning the value to it? To know the issue, use the following code
[PHP]<?
if (array_key_exis ts('_submit_che ck', $_POST)) {
$query = "UPDATE events SET eventTitle = '$eventTitle', eventInfo = '$eventInfo', eventImage = '$eventImage' WHERE eventID = '$id'";
mysql_query($qu ery);
echo $query;
exit;
header("Locatio n: eventsList.php" );
}
?>[/PHP]
This will print the query. Please confirm if the printed query is correct or not.
Post back what did you get from the above code?
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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...
|
by: Bob Kaku |
last post by:
I'm trying to create a text editing and updating capability to help
someone who wants to maintain content on a web page without having to
know any HTML or use a web authoring tool and FTP'ng the contents.
I've already created a screen whereby the person can create new
content with a PHP program that inserts into a MySQL table. But, I'm
having a little trouble in creating the edit/update functionality.
Can somebody help me out? Thanks.
...
|
by: redneck_kiwi |
last post by:
Hi all:
I have a really weird problem. I am developing a customer catalog
system for my company and as such have delved into sessions for
authentication and access levels. So far, I have managed to get a
working system just about finished.
I am building an interface for our customer service folks to use to
manage registered customers and am seeing some weird behavior.
|
by: Federico Bari |
last post by:
Good morning all from italy,
i have probably a compatibility problem with a html/javascript page.
The aim of the code of the file test.htm you find here following (copy the
3 files in the
same directory) is to change the content of a layer, created with the
<div...> tag, with an external text (clicking over an hiperlink) or with the
result of a <form...> submition. The solution (I haven't been able to find
anyone else) is to use a...
| |
by: '~=_Slawek_=~' |
last post by:
I have problem with SQL update. Sometimes it can take 2-10 seconds. I need
to make this update every time page is opened - ASYNCHRONOUSLY.
I have read forums, php.net etc about running php code 'in background' after
all data generated is received by user browser. However i cant simply use
it. Nothing works for me, im on a paid server.
I have checked the headers and all content my PHP outputs is zipped and send
compressed by apache...
|
by: Lag |
last post by:
Having a problem updating my database from a web page, through a
submission form. Can anyone help?
----THIS IS MY CODE IN update.php----(user, pass, and database are
typed in directly, I changed them here for securiy reasons :) )
<?php
/*---CONNECT TO DATABASE---*/
|
by: underground |
last post by:
Hi, everyone I've been trying to figure out a way for a user to update there information. I'm using sections to identify the specific user..Here is the form
<?
include("include/session.php");
?>
<?
$username="xxxxxx";
$password="xxxxxxx";
$database="xxxxx";
|
by: rpjd |
last post by:
I am trying to submit entries in a form to a database. I am using
"
within my submission form and
$_POST
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
|
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,...
|
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...
| |
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |