Webmasterpals  

Go Back   Webmasterpals > Webmasterpals Network > PHP Login Script v2.0

Reply
 
Thread Tools Display Modes
  #1  
Old 04-14-2012, 11:46 AM
emmak_25 emmak_25 is offline
Junior Member
 
Join Date: Mar 2012
Posts: 4
emmak_25 is on a distinguished road
Default required fields

I'm trying to set a required field, the same as with the username on the register page.
This is what I've got
PHP Code:
if(!empty($data['abstract'])) {
        
$err[] = "ERROR - Please enter a valid email";
    }
    if(!empty(
$err))  {
        echo 
"<div class=\"msg\">";
        foreach (
$err as $e) {
            echo 
"* $e <br>";
        }
        echo 
"</div>";
    } 
Reply With Quote

DirTimes Web Directory - Premium General web directory of quality websites. Submit today!

Premium Web Directory - Premium general web directory. Submit your site for Inclusion

  #2  
Old 04-14-2012, 12:18 PM
Wombat76 Wombat76 is offline
Senior Member
 
Join Date: Mar 2011
Location: UK
Posts: 1,049
Wombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond repute
Default Re: required fields

You need to check whether the variable is empty. !empty checks that it is NOT empty. If you want to also check for a valid email address, you can do that at the same time. Leave out the " OR !isEmail($data['abstract'])" if you don't:

PHP Code:
if(empty($data['abstract']) OR !isEmail($data['abstract'])) {
        
$err[] = "ERROR - Please enter a valid email";
    }
    if(!empty(
$err))  {
        echo 
"<div class=\"msg\">";
        foreach (
$err as $e) {
            echo 
"* $e <br>";
        }
        echo 
"</div>";
    } 
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 02:47 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Webmasterpals.com (c) 2008 - All Rights Reserved