Page 1 of 3 123 LastLast
Results 1 to 10 of 24
  1. #1

    Default Help sa register and log in application sa PHP. help will be greatly appreciated


    guys im always getting this error saying Notice: Undefined variable: errors in C:\xampp\htdocs\registerlogin\login.php on line 26. everything is working fine except lang jud ana nga warning. please help

    Code:
    <?php
    include 'core/init.php';
    
    if(empty($_POST) == false)  
    {
    	$username = $_POST['username'];
    	$password = $_POST['password'];
    
    	if(empty($username) OR empty($password))
    	{
    		$errors[] = 'You need to enter a username and password';
    	} 
    	else if(user_exists($username) == false)
    	{
    		$errors[] = 'We cant find that username. Have you registered?';
    	}
    	else if(user_active($username) == false)
    	{
    		$errors[] = 'You havent activated your account';
    	}
    	else
    	{
    		echo 'account activated';
    	}
    
    	echo $errors;
    }
    ?>

  2. #2
    before sa $username or after sa $password, ibutang ni $errors = "";

  3. #3
    since you are using the error variable as an array type. e-define sa na nga variable before using it... perhaps add this after $username and $password variables.

    Code:
    $errors = array();

  4. #4
    wow it worked! thanks kaayo sir! you are a genius!

  5. #5
    yman tuod gi array na nimo TS nga inig print ana Array mn mo gawas?

  6. #6
    Quote Originally Posted by ondoy View Post
    yman tuod gi array na nimo TS nga inig print ana Array mn mo gawas?
    possible reason is he wants to display all errors... its ok if you want to be thorough but not really a good practice... it may slow down the displaying of errors if i loop na.... solution is to use implode....

  7. #7
    mrg usa rmn cguro mabutang ana Bro, kay nag els ep-els ep man

  8. #8
    Quote Originally Posted by ondoy View Post
    mrg usa rmn cguro mabutang ana Bro, kay nag els ep-els ep man

    correction to my post gi echo raman diay niya ug largo ang $errors so i assume nga single message ra diay..


    updated with added security
    PHP Code:
    <?phpinclude 'core/init.php';
    if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['username']) && isset($_POST['password'])) {
        
       $username = $_POST['username'];
       $password = $_POST['password'];
       
       if(empty($username) OR empty($password)){
            $errors = 'You need to enter a username and password';
        }elseif(!user_exists($username)){
            $errors = 'We cant find that username. Have you registered?';
        }elseif(!user_active($username)){
            $errors = 'You havent activated your account';
        }else{
            $errors = 'account activated';
        }
        echo $errors;}?>
    Last edited by salbahis; 10-14-2013 at 02:39 PM.

  9. #9
    Tutorial from PHP academy ni TS sah? hahaha

    - - - Updated - - -

    Quote Originally Posted by salbahis View Post
    correction to my post gi echo raman diay niya ug largo ang $errors so i assume nga single message ra diay..


    updated with added security
    PHP Code:
    <?phpinclude 'core/init.php';
    if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['username']) && isset($_POST['password'])) {
        
       $username = $_POST['username'];
       $password = $_POST['password'];
       
       if(empty($username) OR empty($password)){
            $errors = 'You need to enter a username and password';
        }elseif(!user_exists($username)){
            $errors = 'We cant find that username. Have you registered?';
        }elseif(!user_active($username)){
            $errors = 'You havent activated your account';
        }else{
            $errors = 'account activated';
        }
        echo $errors;}?>

    sir noob question lang , unsa ang mas OK using $_SERVER['REQUEST_METHOD'] or simple $_POST ra? unsay difference nila?

  10. #10
    Quote Originally Posted by luisxcore View Post
    Tutorial from PHP academy ni TS sah? hahaha

    - - - Updated - - -




    sir noob question lang , unsa ang mas OK using $_SERVER['REQUEST_METHOD'] or simple $_POST ra? unsay difference nila?
    yes sir ahehe. kang alex garret ni nga tutorial gikan. thnks kaau sa inyo mga reply. gamit man diay ni istorya.net ui kay kusog mo tabang mga tao diri. dili pa man ko master aning php mao nang ngita kog tabang if d na jud nako kaya hehe

  11.    Advertisement

Page 1 of 3 123 LastLast

Similar Threads

 
  1. unsay 1st forum ang imong e view inig log in nimo sa istorya.net?
    By chill_angel25 in forum General Discussions
    Replies: 201
    Last Post: 09-09-2015, 05:12 AM
  2. Replies: 23
    Last Post: 11-28-2012, 08:33 AM
  3. Replies: 17
    Last Post: 06-28-2012, 03:54 PM
  4. Replies: 0
    Last Post: 02-18-2010, 12:20 PM
  5. ned help abt sa program on log in and out sa cafe......
    By blossom1021 in forum Programming
    Replies: 3
    Last Post: 10-18-2006, 07:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top