validation for users when sign up for event2

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kabucek
Forum Commoner
Posts: 50
Joined: Thu Sep 04, 2008 2:20 pm

validation for users when sign up for event2

Post by kabucek »

Hi @ll,


I have the following function to check when users register to our system.
It validates f.name, l.name and email address.




[*]

Code: Select all

 
    if (implode($errorArray)=='') 
 
                    {
 
                        $checkMemberArray=$memberLink->getRecordMatch('userID', $memberDataArray['emailAdr']);
 
                        
 
                        if ($checkMemberArray)
 
                            {
 
                                $cFirst=strtolower($checkMemberArray['first']);
 
                                $cLast=strtolower($checkMemberArray['last']);
 
                                $mFirst=strtolower($memberDataArray['first']);
 
                                $mLast=strtolower($memberDataArray['last']);
 
                                if ($cFirst!=$mFirst or $cLast!=$mLast)
 
                                    {
 
                                        $command="sendAccountMail"; $destPage=$PHP_SELF; $label="here";
 
                                            $quote="\"";
 
                                            $clickString="onClick=".$quote."document.$formName1.operation.value='$command'; document.$formName1.action='$destPage'".$quote;
 
                                            $hrefString="href='javascript:submitRoutine($quote$command$quote, $quote$formName1$quote)'";
 
                                            if (!$label) { $label=$command;}
 
                                            $$command="<A $hrefString $clickString>$label</A>";
 
                                        $errorArray['emailAdr']="Mismatch email and name";
 
                                        $processMsg.="
 
                                            <DIV class=processMsgError>
 
                                                The email address you entered today has been used in our system with a first and last name that are different than the ones you entered. <P>
 
                                                
 
                                                
 
                                                </DIV>
 
                                            ";
 
                                        }
 
                                    else
 
                                        {
 
                                            $memberDataArray['first']=$checkMemberArray['first'];
 
                                            $memberDataArray['last']=$checkMemberArray['last'];
 
                                            }
 
                                }
 
                        }
                        
                        
 
 
 
How to update this code, so when users try to register even with the good credentials it will give the message:

" You are already registered for this event, if you continue you might be charged again".

If possible use query to connect with database?





?>
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: validation for users when sign up for event2

Post by andyhoneycutt »

You could modify the following to suit your needs:

Code: Select all

$sql_query = "SELECT COUNT(*) as c FROM registration_table WHERE first_name = '$first_name' AND last_name = '$last_name' AND registered_event='$event_registered'";
$result = mysql_query($sql_query,$database_link_identifier);
$registered_times = 0;
while( $row = mysql_fetch_assoc($result) )
{
  $registered_times = $row['c'];
}
if( $registered_times > 0 )
{
  echo "You have already registered for this event. Doing so again may cause your account to be billed more than once.";
}
kabucek
Forum Commoner
Posts: 50
Joined: Thu Sep 04, 2008 2:20 pm

Re: validation for users when sign up for event2

Post by kabucek »

Thanks,

I got with putting another array into that.
I see your way is much better.
What if I want to change f.name & l.name with email instead ? (emailAddr)


Thanks !!
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: validation for users when sign up for event2

Post by andyhoneycutt »

kabucek wrote:What if I want to change f.name & l.name with email instead ? (emailAddr)
You're welcome. Also, you would be able to do that by following the same logic as you would with a first name, last name, or any other criteria you are able to use as long as you have something to compare it against.

-Andy
Post Reply