Thanks to everyone for the suggestions. Got it fixed. Just added a couple
lines of code -
$sql1 = "select * from endusers where name like '$name'";
$result1 = mysql_query($sql1);
$count1 = mysql_num_rows($result1);
if ($count1 == "0" )
$sql = "insert into endusers......blah blah blah
Now it works fine, no more duplicate entries. Just for those who asked -
this is a database of end-user names
and addresses for a mailing list. The questions posted are kept by the
department that responded to them.
No one here has ever asked or implied a need to have the messages saved to
the database, what they do
with the message is their game, not mine. I'm just cleaning up their
existing code a bit.
--
Chip
Miles Thompson <[EMAIL PROTECTED]> wrote on 06/04/2003
08:31:14 AM:
> Chip,
>
> Given that you have duplicate entries, then one field, or a combination
of
> several fields, will probably be unique.
>
> Before adding a record execute a SELECT, using the values from the form
> against that combination. If the number of records returned is greater
than
> 0, then execute an UPDATE query, otherwise an INSERT.
>
> Now, that information is so vague to be almost useless, for it begs a
> number of other questions, such as
> How many questions are end users allowed to ask?
> How are questions flagged for expiration or completion/solution?
> What kind of mix of questions do you allow?
>
> Cookies only store a bit of information on the user's browser. There's
> nothing magic about them - google for "netscape cookies". I don't think
> they'd be much help to you here.
>
> HTH - Miles Thompson
>
> At 01:13 PM 6/4/2003 -0700, [EMAIL PROTECTED] wrote:
> >I need to modify some company web pages that include a form for asking
the
> >company departments questions, such as service dept, etc. As the forms
are
> >currently built there is some field validation but no cookies. This
info
> >is saved in a mysql database, problem is, there are duplicate entries,
> >every time an end-user posts a question. What kind of code do I need
to
> >add to these existing pages to prevent duplicate entries in the
database?
> >(Manually scanning through and deleting dupes is a real drag.) And what
> >about cookies? Could I make use of these on these pages? I haven't
worked
> >with cookies yet, so am not sure where to start with that part.
> >Thanks,
> >--
> >Chip
> >
> >--
> >PHP Database Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php