You are here: Re: on input form showing error message for duplicate entry. « All PHP « IT news, forums, messages
Re: on input form showing error message for duplicate entry.

Posted by Steve on 10/18/06 14:15

".:[ ikciu ]:." <no@mail.com> wrote in message
news:eh3qm5$9g1$1@news.dialog.net.pl...
| Hmm linda <newsaccount@tiscali.co.uk> wrote:
| > a) The product code is the ID, this is beyond my control as the
| > products come from the supplier with these codes on. Yes I realise I
| > could have set id to auto_increment, and then have another field for
| > the product code, but I thought that as certain products HAVE TO HAVE
| > a unique code it would be just a waste having an id field with
| > auto_increment. Besides which it would be the product code that would
| > be used for searching the data base, so i decided this would be set
| > to primary and unique.
|
| make same form for for update and insert
| $whatAction = array(1=>'add', 2=>'edit');
|
| if this is edit then you should to get data from db
|
| if this is insert then you user will fill form (you can use js or WF2 for
| user side validate) after submit
| you have to validate all values, then if there is error show info,
otherwise
| add your post data to session
| make redirection to other php file where you will insert / update it in db
| (in this case this is not important because there is no way to add same
| value to db, but any way you can do it in right way)
| in other file you will just make correct db data (mysql_real_escape_string
| for string fields) and you will do insert or update dependent of value
| $whatAction which you will store in session too if you will do insert and
| you will have1062 error it means the id is taken - then back to previous
| file, show typed data in fileds and ask user for retype ID do it until you
| will have no error
|
| if it is update then np, just do it
|
| remeber after each db operation you should to check result - there can be
| few case when someting will go wrong,
| at the and unset session variables and it is done
|
|
| if you use code ID as a primary key, then there is no reason to set same
| value for this field
| so just do insert if your mysql_query will return you error code 1062 it
| means the id is taken
| and user should to type new value for this field - show him info
|
| if you know this is edit just use update

maybe someday you'll learn to read the question for comprehension and give
advise that actually DEALS WITH THE PROBLEM. as it is, you still don't get
her question even though she's spelled it out clearly, twice! perhaps your
first response should have addressed YOUR stupidity in ANSWER HER QUESTION
rather than HER stupidity in ASKING it!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация