Click here to get back home

Have a data entry screen

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Have a data entry screen dba 07-10-2008
Get Chitika Premium
Posted by dba on July 10, 2008, 8:24 pm
Please log in for more thread options
with html and php using mysql.

How do I catch error's from a database like "duplicate entry" and display
something on the entry screen.

Also how do you clear the data boxes on a screen. When I use 'go back on
page' the data remains.


Thanks

Posted by Jerry Stuckle on July 10, 2008, 9:10 pm
Please log in for more thread options
dba wrote:
> with html and php using mysql.
>
> How do I catch error's from a database like "duplicate entry" and
> display something on the entry screen.
>

It depends on the database. Check the manual for the calls associated
with your database.

> Also how do you clear the data boxes on a screen. When I use 'go back on
> page' the data remains.
>

You can't easily. Much of the time this doesn't even call the server -
just fetches the page from the local cache. Of if it does, it calls
with the same POST or GET parameters as before, so your script does the
same thing.

You can try setting a session variable and, if it is set, clear the
values from the screen. But then when do you reset this variable?

>
> Thanks
>



--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================


Posted by Geoff Berrow on July 11, 2008, 4:18 am
Please log in for more thread options
contained the following:

>> How do I catch error's from a database like "duplicate entry" and
>> display something on the entry screen.
>>
>
>It depends on the database. Check the manual for the calls associated
>with your database.

The big problem with preventing duplicate entries is deciding what
exactly constitutes a duplicate. For instance Rothesay Ave. could be
the same as Rothesay Avenue. And Rothsay Avenue may well be the same
too. Unless you can identify an attribute or set of attributes which
will uniquely identify the record, you may well just have to work round
it.

Sometimes you are only bothered about duplicates due to people
submitting a form twice. To prevent this I save the insert query as a
session variable (you may have to leave out any time sensitive info).
Before the insert I then check against this variable and if they match
show an error message.

I find that starting a session on the form page clears input values form
the form but the downside of this is that users have to add the entries
again if there is an error. So I store these values temporarily as
session variables. On a successful insert I clear all the session
variables.

So the process is form page->error/successpage (if there is an error
link back to form page)

I use javascript validation to enhance the experience of users with JS
enabled but of course always double check using php before insertion
into the database.

--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011

Posted by macca on July 11, 2008, 3:52 am
Please log in for more thread options
>with html and php using mysql.

> How do I catch error's from a database like "duplicate entry" and display
> something on the entry screen.

Use a try-catch statement such as this: (example uses PDO)

try {
$db->Query("ERRONEOUS SQL QUERY");
} catch(Exception $e) {
// If an error occurs
echo "We caught the error: " . $e->getMessage();
}

Similar ThreadsPosted
DATA ENTRY January 7, 2006, 5:04 pm
If, And, Or code for data entry June 13, 2007, 10:23 pm
Need help setting up data entry pages. Please help with code. August 2, 2004, 4:48 pm
php adodb data entry form question January 5, 2005, 1:23 pm
Data entry form with long list to choose from June 16, 2008, 3:37 pm
Do online Data Entry Jobs for more than 50 International companies directly on their working server. February 24, 2008, 7:00 am
ldap and entry attributes August 9, 2007, 3:44 am
MySQL question- random entry November 7, 2005, 2:53 pm
Prevent duplicate record entry December 20, 2007, 7:57 pm
MySQL date, and time entry issues. October 17, 2006, 5:02 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap