Re: If else Question
| From: | Adam Royle | Date: | Tue, 26 Mar 2002 09:30:35 +0000 |
| Subject: | Re: If else Question | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-17913@lists.php.net to get a copy of this message | ||
Maybe I am missing something but it seems you are doing things in a potentially unreliable way.
Firstly... your sql statement in create.php
$query_update = "INSERT INTO pets (uid) SELECT uid FROM users WHERE
uid={$session["uid"]}";
could simply be
mysql_query("INSERT INTO pets SET uid = " . $session["uid"]);
if you are using php4 session variables, why don't you use $uid as the session,
so you would only need --> mysql_query("INSERT INTO pets SET uid = $ID");
Moving on...
I don't know why you would create an empty record, and insert data later if it is allowed.
Do this:
Show Form --> Submit Form --> Check Data Integrity --> Check If Allowed to Insert Record --> Insert Record
If anything stuffs up then you don't do the bit following.
So it doesn't check data integrity if you haven't submitted the form (obvious) and it doesn't insert the record until it checks the data integrity and if they are allowed to insert the record.
Adam.