alerting redundant field to user

images php coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2192
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Thu Nov 11, 2010 6:01 am

why is this in an Images forum?

User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2192
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Thu Nov 11, 2010 10:48 am

a.) I wouldn't use an email address for primary keys or UNIQUE fields. I would use Integers because it's MUCH faster.

b.) You can put a "UNIQUE" field on the email address, to ensure that you have one copy of email in your db for one single user, no problem there, just be aware that doing so will chew up disk and cpu.

c.) $query = "SELECT email FROM my_table WHERE email='$_POST[email]'"; // <-- This IS NOT SAFE.. you should use some kind of filtering, error checking, etc.. I used this as a pure example, and nothing more. //
$result = mysql_query($query);
$numrow = mysql_num_rows($result);
if ($numrow == 1) {
$user_error['email_address'] = "The E-Mail Address is already in use.";
} else {
do this..
}
Last edited by egami on Thu Nov 11, 2010 11:51 am, edited 1 time in total.

User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2192
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Thu Nov 11, 2010 11:07 am

no, it wouldn't be any trouble at all. The field name of a table has no correlation to the field name of an HTTP_VAR.

You can name a field "kitten" and the name of the field be "puppy"

just have to assign it as such on the backside.

INSERT INTO my_table (kitten) VALUES ('$_POST[puppy]')

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests