Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Form Update


I have a form that sends data to mysql, and you get shown the submitted data. But i also want the users to be able to update their sent info, after thay see what they've sent, to make changes if something was incorrect. I want to make an update feature that will let them do that, but their is no user authentication on these pages, so i want to use php session. I don't know where to start.

I want the form data to be saved in the session, so when they go to the update page, their info is still there. I want the session to end after they update.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Update From Form
The file below is supposed to bring up a form with the fields for a user inserted into it for editing. "edit.php?id=83" is an example of the link to it. When that link is clicked the page is empty and the is no code in the source view.

<?
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="select from todo where id='".$_GET['id']."' LIMIT 1";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();

$i=0;
while ($i < $num) {
$item=mysql_result($result,$i,"item");
$description=mysql_result($result,$i,"description");
$category=mysql_result($result,$i,"category");
$priority=mysql_result($result,$i,"priority");

?>

<form action="updated.php">
<input type="hidden" name="ud_id" value="<? echo "$id";?>">
Item: <input type="text" name="ud_item" value="<? echo "$item"?>"><br>
Description: <input type="text" name="ud_description" value="<? echo "$description"?>"><br>
Category: <input type="text" name="ud_category" value="<? echo "$category"?>"><br>
Priority: <input type="text" name="ud_priority" value="<? echo "$priority"?>"><br>
<input type="Submit" value="Update">
</form>

<?
++$i;
}
?>

Php Form And Update Sql
Im using a php user system from source forge and modifying it.  I just want to test updating sql from a submit button.  So say when button is clicked the new value either as a actual value or an addition like below can be passed to the database and then the value returned as a print or echo.

if ocassionaly managed to get the value to update (i checked the sql database) but it doest work at showing the updated value and now its completely broke.

Can anyone who understands what im trying to do either look over what ive got and correct or write a simple version of what I should be doing. Code:

PHP Form Field Update...
I am sure this has been answered here somewhere, but I have searched for a good 2-3 hours and can't seem to locate a solution. Additionally, I really don't want anyone to solve this mystery for me (at least not all the way!) - But I was hoping someone could point me in the right direction here.

I am trying to figure out how to update form field information before the end user hits the submit button - for example, if they select that they are from California from the "state" drop down list, only counties from California would show up in the "county" drop down list. BTW, this is only a hypothetical example - I am only using this code to build a photo manager for my website!

Anyone able to:

1) tell me what this process is called - it's hard to search for answers when you don't know what you're looking for.

2) point me in the right direction of a solution.

Form -> Array -> Update
I have a form which lifts 20 items at a time out of a db table. Against each record I place a textbox for suggested changes, and the relevant line in the form is: PHP Code:

Dynamic Form Update
I have the following form in which i need to updateitems.
The problem is that i do not know how many elements will be in the form
(generated dynamically)

eg
<input type = "hidden" name ="id1" value="1"><input type ="qty1" value ="1">
<input type = "hidden" name ="id2" value="2"><input type ="qty2" value ="1">
<input type = "hidden" name ="id3" value="3"><input type ="qty3" value ="5">
<input type = "hidden" name ="idn" value="n"><input type ="qtyn" value ="1">

how do i generate an array for a foreach loop to update the values in PHP
so that i can use it to create a Update query
eg
///begin loop
$sql = "UPDATE `table` SET `qty` = `$qtyn` WHERE `id` = `$idn`";
// end loop

Update Database Using A Form
i would like to up date i have the following fields;

Prod_ID
Prod_Desc
Date_sent_in_house
Used_by_date
Supplier
Cases_sent
Cases_sold
Price_p

from a form i would like to enter new data into the database table., but unsure on how do do this can you help?

Can't Update Mysql Table Via Php Form
I have a form that updates an item pulled from a database, but after the form is posted, it does not update the mysql database with the new info, here's what I am using: Code:

How To Update MYSQL From Multi Row Form
I'm trying to update rows in MySQL using a dynamically generated form. PHP Code:

Update 2 MySQL Tables In One Form
I have a form with two fields in it. Each field updates its own table. I would like for the user to be able to enter data in either fields and the form update the appropriate tables. If one of the fields is empty then it doesn't update the table.

mcat - Updates mcatTable.mcatname
mtype - Updates mtypeTable.mtypename
PHP Code:

Form Fields To Update A Webpage
I am trying to build this mini "publishing" system and allows the user to use form fields to update a webpage (images and text) then press a button to email that webpage to a list of emails. (spamming own userbase). I will have a webpage with php code in it and the code will pull data from the db.

How can I save the file has a static html file so that I can pass it to my mail function? or can I directly pass the php page to the mail function? or what is the best way of doing this? I also have to learn how to do file upload with php aswell.

Update Page Content From A Form
I want to have a web page that uses variables from a text file as some of its content.
I want another page with a form that will allow me to updated/change the variables in the text file. I have no need to add variables using the form only change the values of existing variables.

Basically I want to make some content on one of my pages update-able using a form; not entire paragraphs just single words that I have laid out in a table. I have been told that I should just use something like mySQL for this. I do not know if it is necessary since I only want to do it to one page.

Update Form, Security Issue
I have to write secure update record php script, here are the complete
details of the website,

the website has a login system that authenticates the user, writes the
session ID for username and goes

on.

The user can post, read msg he can also update the msgs that he had
posted in the past once he is

loged in.

when user tries to update the msg, the script check MySql DB with

select * from Msg where username = session ID

suppose recorset returns msg number 1,3,5,7,9 with that perticular
username.
I pass the user to a page ...update.php?msg_id=1 and the user can
update the stuff.

Everything is working fine,

Problem

what if the user changes the url to ...update.php?msg_id=2

he can still update the record, what to do he has not posted msg id 2.
what sort of method or code

should i use to restrict him to the msg that he posted

If you feel that i am using a bad method or my database structure
should have a new field please let me

know coz I can still make changes in DB structure as well as my
scripts we are in the somewhat initial

stage of the development of the product.

Displaying Information In A Update Form
I can display the information in a table.  But now I need to display it in a form, so I can edit it and then upload it to the database.  I have the form from my upload page, But I can not seem to get the information to appear back in it. Code:

Dynamically Generated Form And Update Problems
In brief, in the following 2 portions of code I build a form based on data retrieved from a database. The second bit of code receives the posted data for processing and updating the database. Problem is that the update occurs for the first row of data but none of
the rest. I'm using a hidden field, written in dynamically (
name="tfHiddenId<?php echo $j ?>" ) where $j is a counter var in a loop.

When I print out the POST_VARS everything is as I want to be, fields all
named according ly, as above. Just the update either 1) only does one
row and quits or 2) updates same row with the same data over and over ( I
suspect the latter ). Apparently my counter variable is not being incremented, but only on one var, "tfHiddenId".$i , on the receiving page. Here's the code for where the form is built from the DB: PHP Code:

Form Data Array - Need To Update Table
I have a form that is dynamically generated by the fields I have in a table. This table generates the navigation for my site, and I want to create a page that will allow me to reorder and hide/show and activate/deactivate the links. The form is working and I have the form generating an array based on the data collected on submit. I need to know how to break this data apart so I can update my site navigation table with the correct values. The table looks like this:

Update A Ststic HTML Form To Dynamic
I have a form which I now want to be more dynamic. The datbase tables are builtbut I cannot get the fields to populate.

When a member selects an age group from the first select statement and the dates that age group are scheduled to play a match are displayed in a second select statement. When both select ions have been made the rest of the form is displayed and can be filled in and the database updated. Code:

Need To Update Multiple Mysql Records With A Single Form Submit
I have a wish list like a shoping caty based on a mysql databse where i retrieve records with php I need to update the quantity which is in a text fields :

input type = text name = quantity[] value = $quantity
input type = checkbor value = $id name = id[]

I need to update quantities based on the primary id represented with id with a single submit.

How To Update Form Input Field Background Colour On Validation Error
I have been searching for form validation scripts for ages and all th ones that I like are far too complicated and inflexible so I decided to stick with my own which is easier to understand.

The only thing I don't like which i have seen on better form validation scripts is that and fields with errors are highlighted.  i can only presume that they have used php to set the background color of the input field or textarea.

How would I add some code to change the background colour of form elements if an error is found? Here is my code which validates the form but doesn't change form elements colours. Code:

Have To "actions" Or Run Two Types Of Queries (select,and Update) On The Same Form?
I had a brilliant idea on one of my pages that selects some data from
my mysql database.
I first set the page up to display some info and an image, just one
item, with a row of data, etc.

then I thought it would be nice to do a select, and perhaps an update
(the title of the image) on the same page.

I am wondering if I am having the wrong idea. I have a form, with two
submit buttons, one selects an image, and some info. the other will
update the image title for the given image (id, and p).
I am seeing that I have a mistake here, since it seems the update
query will run as well as when the select query is run (select button
clicked). this overwrites my image titles in the db.

I have the wrong idea, but have not seen how to do this "right". I
could use another php page for update, but I am guessing this can be
done from the same page.

Below is my poor code - i am not an expert programmer!!! any help,
suggestions will be helpful.

<?php

$img = $_REQUEST["img"];
$p = $_REQUEST["p"];

echo '<div class="input">'."".'</div>'
//connection files for mysql
@include 'c:/php/includes/db.inc'
@include 'c:/php/includes/error.inc'
//***@include '/usr/local/php/include/db.inc'
//***@include '/usr/local/php/include/error.inc'
//@require_once '/usr/local/php/include/size_image.php'

Select And Update Vs Update
For doing update or insert code, its worth noting that Example 1 seems to be around 60% faster than Example 2 PHP Code:

Server-Side Form Submission - Form Submits To Form, Which Autosubmits. BAD!
I have a php form from which the user fills out their name and address and clicks "Submit".

The form goes to a page that stores the data in a mySQL database, then, using hidden fields, populates another form and actives with a javascript onLoad=submit() to send the information on to the final destination.

I cannot control or edit the final destinations web page, which is why the interim page is needed.

What I would like is for the user to fill out the form, and upon submission have the data recorded into the database and have the data passed on in a "form like way" on to the final destination BY THE SERVER, not by the use of a hidden form page that auto submits.

Any suggestions?

Here is the interim page's code below:

<?
$link = @mysql_connect($db_host_name, $db_name, $the_decoded_password) or die;
@mysql_select_db($db_name) or die;

$query = "INSERT INTO web_link VALUES ('', '$a', '$b', '$c','$d', '$e', '$f', '$g', '$h')";
$result = @mysql_query($query) or die;
?>
<html>
<head>
</head>
<body onLoad="document.contactme.submit();">
<form name="contactme" method="post" action="http://www.test.com/cgi/storethisdata" >
print "<input type="hidden" name="first_name" value="$first_name"><br>";
print "<input type="hidden" name="last_name" value="$last_name"><br>";
print "<input type="hidden" name="email" value="$email"><p>";
print "<input type="hidden" name="phone" value="$phone"><p>";
?>
</form>
</body>

</html>

Update?
I would like to update certain records in database so they are all written in lowercase....i have tried with it but doesn't work:

<?php
$db = mysql_connect("$host", "$user");
mysql_select_db("albums",$db);
$result = mysql_query("SELECT * FROM albums",$db);
while ($myrow = mysql_fetch_row($result)) {
$al_artist = strtolower($myrow[1]);
$al_name = strtolower($myrow[2]);
$site = strtolower($myrow[4]);
$sql = "UPDATE albums SET al_artist='$al_artist', al_name='$al_name' site='$site' WHERE id='$myrow[0]'";
$query = mysql_query($sql);
}
mysql_close($db)
?>

Update
I am updating the column ourpage in any row of the database busdir2 where cat = farming. It reads only rows where cat = farming correctly, but isn't getting the new ourpage value into the table. Code:

Using UPDATE
I wish to update particular fields in a mysql table I have created, which I would like to do using PHP. I'm using the UPDATE command from mysql. Does it work with PHP? I have an HTML form, which gets variables for the following;

$Code (my primary key to identify the record),
$field (The particular field I want modified),
$Input (The new data that I wish to update into the specified field),

My PHP query is looking something like; Code:

Update SQL
I've been working on a PHP/MySQL website for a while. I thought everything was working originally, but now it seems my update has stopped working. It doesn't throw up an error, but the information is just the same as before. PHP Code:

Txt Update
I got this script that reads a textfile line by line and compares it to a searchstring from the user. If a match is found the line will be echoed to screen for editing ie in a textarea. Multiple searchresults may occur. Hvor can get the updated data back into the string which contains all the data? In other words, how do I update the txt contents?

Update Sql
UPDATE queryies:

i know that you can select multiple tables with SELECT queryies, but is it possible to update many fields from two tables??

eg UPDATE table1, table2 SET table1.field = '', SET table2.field4 = ''

is that posible

UPDATE And TIMESTAMPS
Is there a way to stop mysql TIMESTAMP fields from updating automatically when doing any UPDATE query?

For example, I have columns storing when users sign up, and the last time users login, but they automatically update when I use a query.

Session Update
Err for some reason my code is not.. working.. it suppost to create a session... and insert it to the db.. and then update on every page refresh.. just update the time.... and if they dont update in less then 2 minute.. then delete there session from the table..

UPDATE Columns With PHP
So you know I'm going through Kevins book.

I'm updating data in a test table. I'm adding names to each joke, say I have 7 jokes and 3 of them go to the same person. I can update each one seperately but I can't find a way of bulk updating. In this case it's not a problem.

I've looked though Kevins book and a couple of others but can't find anything. Tried several sites to but I may just be searching wrong.

I can do this:
mysql> UPDATE Jokes SET AID="1" WHERE ID=2;

but I'd like to update WHERE ID equals 2,3,4,5 all at once.

Update/requery Db
I have setup a table with 1 row and 2 columns.In the 1st, I have a
iframe that displays tons thumbnails of images. In the next I have an
image (enlarged). When the user selects a thumbnail it displays the
enlarged image in the 2nd column. This work quite nicely.
Where I need some help is with the fact that each image has an entry...

Update Query
I am having a problem with the update script. I making a group update and i keep on getting "cant execute query" error. I am wondering if its my SQL statement. PHP Code:

Need Some Help With Update Function
What I would like to do is have a simple form where the user can log on and update a list of neighborhoods.

The DB has a table called "neighborhoods".

I have the form set up to display the data from the table within a text area, so taht the user can make any changes, click "update" and it sends the new data back to the table.

Problem is, I've fooled around with insert, and it is creating new rows and thus duplicating the data. I've played with UPDATE but can't seem to get it to work. If anyone can give me a hint as to where I am going wrong, I would appreciate it. Here's the code:

$query = "update neighborhoods SET
('".$_POST['neighborhoods']."')";
$result = mysql_query($query)
or die ("Unable to Add item. Please contact administrator");

The form is obviously posting one field, "neighborhoods". If I use "Insert Into..." in the query, it adds another row. Essentially all I want to happen is for the new $_POST to replace the existing data in the table.

Insert/update
I came accross a little piece of code today that I thought was quite
cute, but I'm not sure if it's any better than my usual method. The
code ultimately needs to see if a unique identifier exists in a
database, then either insert or update accordingly.

The way I've always done it is:

SELECT * FROM blah where.....

if (there's a row) then
UPDATE.....
else
INSERT

but the nifty bit of code did it like this.

UPDATE....
if (mysql_affected_rows == 0) then
INSERT

PHP And SQL UPDATE Problem
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 (content-length header filled automatically). Is there
any way of running SQL query asynchronously to PHP script (so send query to
SQL, query is placed in some buffer and function returns immediatelly?)

Using UPDATE In MySQL
I have an input form that passes data when submitted to a second form
to let the user know what they have just entered into the db.

My question comes with using 'update'. I'd like to query the database
by equipment number (equipno is unique) and query all fields from that
row, populating an original form 'look alike' whereby the user can add
detail to the original records as the db builds. I'm using 'date'
twice because I'd like to have the original date the record was added
plus the most recent update date.

Form 1 below, is original user input:

Array Update
If I want to update a part of an array, do I need to rebuild the array or can I just specify a new value for the key? PHP Code:

MySQL UPDATE
mysql_query("UPDATE news SET newstopic = '$newstopic', news = '$news', newswriter = '$newswriter' WHERE nID = '$nID'");

why isn't this working?

Update Statement
I have managed to re-script my file to remove errors. I am trying to Update the a DateTime field. I have tried everything and searched everywhere possible to resolve the issue. Code:

UPDATE Or REPLACE?
Should I use UPDATE or REPLACE? Say I have a user profile that I want to change via a form. I want the form to replace just the "new changes" to the user profile in the database. I am having no problems INSERTing new information in a table. I just can't figure out how to update a field in a table. Below is the code:

Update Syntax
mysql_query("UPDATE scfmforening SET scfmpad=$scfmpad, scfmpnm=$scfmpnm,
scfmort=$scfmort, scfmwww=$scfmwww, scfmwww=$scfmwww, scfmept=$scfmept,
scfmkom=$scfmkom WHERE scfmnum=$scfchknum ");

UPDATE And Increment By 10
i want to update each field in a database table and increment by 10.

so it will look like

10, 20, 30, 40, 50

Update Check!
i update a table like this and i want to check if the update was ok or not! Code:

How Do I Update Mysql
i have a mysql database table called email2 mysql> describe email2;

+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| id | int(11) | | PRI | NULL | auto_increment |
| email | varchar(20) | | | | |
+-------+-------------+------+-----+---------+----------------+

I want to update the database with a form. For example, i could edit the contents of the database using a form and save it to the database again. Is there way to do that? Code:

Mysql_error On An Update
What's the best practice for handling the following situation, when I
do an update like this:

$sql = "UPDATE haha SET papa="loco" WHERE id=$var";
$res = mysql_query($sql,$db);

If I don't get a match in my where clause, i.e., 12!=44 the UPDATE does
not occur but mysql_errno == 0 and mysql_error = "" so I can't capture
the failure.

Update Once A Day If Not Using Crontab?
How is the best way to only run something once a day? I'd rather not run a crontab so how do I do it the least stressful way on the server?

Update TIMESTAMP
How do I do to update my TIMESTAMP field?

INSERT OR UPDATE?
I am writing an app in PHP that uses a PostGres database.
One thing i have noticed is that what should/could be a single line of
SQL code takes about 6 lines of PHP. This seem wasteful and redundant
to me.

Here is a sample of what I'm talking about ($db is a PDO already
defined and created).

$query[1] = "UPDATE my.table, SET somefield = '$someval' WHERE
somecondition";
$query[2] = "INSERT INTO my.table (somefield) VALUES ('$someval')";
if(!$db->query($query[1])){
$db->query($query[2]);
}

What I'm curious to know is if there is some way to simplify this,
either buy some PHP builtin or extension, or possibly something in SQL
I am missing. It seems to me that "UPDATE OR INSERT", should be valid,
but I can't seem to find anything relevant at all about it.

Anyways I hope you don't mind, but I'm crossposting this to
pgsql.general and comp.lang.php to see if I can get some information on
the subject.

Update Script Help
I'm having a really hard time making a script to update fields in mysql. I managed to make the add script, but haven't been able to figure out a simple update script. Can someone help out? I just need to do a form where the user can input updated data in to keep it current. Here is what the database looks like:


Copyright © 2005-08 www.BigResource.com, All rights reserved