DevFuse Forums: Login form but need a check done - DevFuse Forums

Jump to content

View All ProductsRandom Products

Manage Calendars

Calendar Topics



IP.Board: IPB 3.1.x
Price: $ 9.95
Personal Message

Auto Birthday Greeter



IP.Board: IPB 3.1.x
Price: $ 10.95
Main Page

Timeslip System



IP.Board: IPB 3.1.x
Price: $ 18.95
Example Topic

Auto Anniversary Greeter



IP.Board: IPB 3.1.x
Price: $ 10.95
Global Messages Public View

Global Messages



IP.Board: IPB 3.1.x
Price: $ 21.95
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Login form but need a check done

#1 User is offline   Lindsey 

  • Advanced Member
  • Group: Customers
  • Posts: 97
  • Joined: 11-August 08
  • Gender:Male
  • Location:Australia
  • IP.Board Version:IPB 2.3.x

Posted 09 September 2009 - 08:44 PM

Hello,

Right, so what I'm trying todo is have http://mysite.com/index.php as my main site splash page. Now on that splash page I have a login form. (Code is below.) What I need down is to hook it into a forum so it validates the login or not.

But if the login is incorrect it will go back to http://mysite.com/in...act=loginfailed

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<title><?php echo $_SERVER["HTTP_HOST"] ; ?> :: Log In</title>
		<style type='text/css' media='all'>
			@import url('http://<?php echo $_SERVER["HTTP_HOST"] ;?>/main.css');
		</style>	
	</head>
	<body><p>&nbsp;</p>
		<form id='install-form' action='index.php' method='post'>
		<input type='hidden' name='_sd' value='b%3A0%3B'>
		<div id='ipswrapper'>
		    <div class='main_shell'>
		 	    <div id='navigation'>
					<ul id='section_buttons'>
						<li class='active'><span>Log In</span></li>

					</ul>				</div>
		 	    <div class='content_shell'>
		 	        <div class='package'>
		 	            <div>	            
    		 	        <div class='content_wrap'>
                <div style='clear:both'></div>      
				<h2> This Login system is still in the works.</h2>
				<input type='hidden' name='do' value='login' />
	<br />
	  <fieldset>
      <legend>Log In</legend>
		<div id='login_controls'>
			<label for='username'>Sign In Name</label>
			<input type='text' size='20' id='username' name='username' value='UserName'>

			<label for='password'>Password</label>
			<input type='password' size='20' id='password' name='password' value='PassWord'>      </div>
  </fieldset>
            		 	        <br />       		      <div style='float: right'>		 
			  <input type='submit' class='nav_button' value='Next >' />			
			  &nbsp;		
 </div> 		 	      								
    		 	            </div></div></div></div></div></div></form></body></html>



So in other words,

Fill in login form > Click next > Checks against a forums database if user/pass is valid > If not valid, goes back to index.php and shows an error. > But if valid, goes to a whole different file.




















.
0

#2 User is offline   Michael 

  • Management
  • Group: Management
  • Posts: 2,348
  • Joined: 22-September 05
  • Gender:Male
  • Location:Australia
  • IP.Board Version:IPB 3.0.x
  • First Name:Michael

Posted 09 September 2009 - 09:09 PM

Have you seen this article here? Should do what you want. I've adapted the code a bit for you. If you need further help integrating with your script let me know.

<?php

/**
* initiate ipb functions
*/
$ipblink = new ipbAuthentication;

/**
  * logging a user in
  */
if(isset($_REQUEST['username']) && isset($_REQUEST['password']))
{
	$returnCode = $ipblink->doLogin();
	
    if( $returnCode == 'SUCCESS' )
    {
    	// login success, redirect.
    }
    else
    {
    	// login faile, display error
    	print $returnCode;
    }
}
else
{
    // no login details provided
}


class ipbAuthentication
{
    /**
     * initialisation function to setup IPSregistry
     */
    protected function init()
    {
        /**
         * Edit this path, to where you have your forum installed.
         */
        $forum_path = 'ipb303';

        /**
        * We will change directories so that proper directory is picked up
        */
        chdir( $forum_path );

        /**
        * Get some basic IPB files
        */
        define( 'IPB_THIS_SCRIPT', 'public' );
        require_once( $forum_path . '\initdata.php' );

        /**
        * Get IPB registry
        */
        require_once( IPS_ROOT_PATH . 'sources/base/ipsRegistry.php' );
        require_once( IPS_ROOT_PATH . 'sources/base/ipsController.php' );

        /**
         * initialise the ipsRegistry
         */
        $this->ipbRegistry    = ipsRegistry::instance();
        $this->ipbRegistry->init();
    }
    /**
     * logs a user in, username and password should be in $_REQUEST['username'] and $_REQUEST['password']
     */
    public function doLogin()
    {
        /**
         * call the initialisation function
         */
        $this->init();

        /**
         * get the IPB login handler wrapper
         */
        require_once( IPS_ROOT_PATH . 'sources/handlers/han_login.php' );

        /**
         * setup the handler class
         */
        $login  = new han_login( $this->ipbRegistry );
        $login->init();

        /**
         * verify the login and do any necessary tasks. form variables must be called 'username' & 'password'
         */
        $login->verifyLogin();
        
        return $login->return_code;
    }
}
?>

DevFuse - My IP.Board development forums. Read my development blog here.

View My Paid Mods | View My Free Mods | Twitter Updates
0

#3 User is offline   Lindsey 

  • Advanced Member
  • Group: Customers
  • Posts: 97
  • Joined: 11-August 08
  • Gender:Male
  • Location:Australia
  • IP.Board Version:IPB 2.3.x

Posted 09 September 2009 - 09:25 PM

Never seen that article :).

Kinda confused tho, How would I add this into the html part of things?

<?php

/**
* initiate ipb functions
*/
$ipblink = new ipbAuthentication;

/**
  * logging a user in
  */
if(isset($_REQUEST['username']) && isset($_REQUEST['password']))
{
        $returnCode = $ipblink->doLogin();
        
    if( $returnCode == 'SUCCESS' )
    {
        // login success, redirect.
    }
    else
    {
        // login faile, display error
        print $returnCode;
    }
}
else
{
   // no login details provided
}


class ipbAuthentication
{
    /**
     * initialisation function to setup IPSregistry
     */
    protected function init()
    {
        /**
         * Edit this path, to where you have your forum installed.
         */
        $forum_path = 'devforums';

        /**
        * We will change directories so that proper directory is picked up
        */
        chdir( $forum_path );

        /**
        * Get some basic IPB files
        */
        define( 'IPB_THIS_SCRIPT', 'public' );
        require_once( $forum_path . '\initdata.php' );

        /**
        * Get IPB registry
        */
        require_once( IPS_ROOT_PATH . 'sources/base/ipsRegistry.php' );
        require_once( IPS_ROOT_PATH . 'sources/base/ipsController.php' );

        /**
         * initialise the ipsRegistry
         */
        $this->ipbRegistry    = ipsRegistry::instance();
        $this->ipbRegistry->init();
    }
    /**
     * logs a user in, username and password should be in $_REQUEST['username'] and $_REQUEST['password']
     */
    public function doLogin()
    {
        /**
         * call the initialisation function
         */
        $this->init();

        /**
         * get the IPB login handler wrapper
         */
        require_once( IPS_ROOT_PATH . 'sources/handlers/han_login.php' );

        /**
         * setup the handler class
         */
        $login  = new han_login( $this->ipbRegistry );
        $login->init();

        /**
         * verify the login and do any necessary tasks. form variables must be called 'username' & 'password'
         */
        $login->verifyLogin();
        
        return $login->return_code;
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<title><?php echo $_SERVER["HTTP_HOST"] ; ?> :: Log In</title>
		<style type='text/css' media='all'>
			@import url('http://<?php echo $_SERVER["HTTP_HOST"] ;?>/main.css');
		</style>	
	</head>
	<body><p>&nbsp;</p>
		<form id='install-form' action='index.php?action=login&do=submit' method='post'>
		<input type='hidden' name='_sd' value='b%3A0%3B'>
		<div id='ipswrapper'>
		    <div class='main_shell'>
		 	    <div id='navigation'>
					<ul id='section_buttons'>
						<li class='active'><span>Log In</span></li>

					</ul>				</div>
		 	    <div class='content_shell'>
		 	        <div class='package'>
		 	            <div>	            
    		 	        <div class='content_wrap'>
                <div style='clear:both'></div>      
				<h2> This Login system is still in the works.</h2>
				<input type='hidden' name='do' value='login' />
	<br />
	  <fieldset>
      <legend>Log In</legend>
		<div id='login_controls'>
			<label for='username'>Sign In Name</label>
			<input type='text' size='20' id='username' name='username' value='UserName'>

			<label for='password'>Password</label>
			<input type='password' size='20' id='password' name='password' value='PassWord'>      </div>
  </fieldset>
            		 	        <br />       		      <div style='float: right'>		 
			  <input type='submit' class='nav_button' value='Next >' />			
			  &nbsp;		
 </div> 		 	      								
    		 	            </div></div></div></div></div></div></form></body></html>

0

#4 User is offline   Michael 

  • Management
  • Group: Management
  • Posts: 2,348
  • Joined: 22-September 05
  • Gender:Male
  • Location:Australia
  • IP.Board Version:IPB 3.0.x
  • First Name:Michael

Posted 09 September 2009 - 11:41 PM

You'll need to change the form to point to the same page, something like this. You could always have the login script on a separate page. Depending on how complex you want this, IPBSDK for IPB3 might be a better option, it would have more functions and probably easier to use.

<?php

/**
* initiate ipb functions
*/
$ipblink = new ipbAuthentication;

/**
  * logging a user in
  */
  
if( isset($_POST['username']) && isset($_POST['password']) )
{
    $returnCode = $ipblink->doLogin();

    if( $returnCode == 'SUCCESS' )
    {
        // login success, redirect.
        header('Location: http://www.yoursite.com/diff_file.php');
    }
    else
    {
    	print $returnCode;
		exit();	
    }
}

class ipbAuthentication
{
    /**
     * initialisation function to setup IPSregistry
     */
    protected function init()
    {
        /**
         * Edit this path, to where you have your forum installed.
         */
        $forum_path = 'ipb303';

        /**
        * We will change directories so that proper directory is picked up
        */
        chdir( $forum_path );

        /**
        * Get some basic IPB files
        */
        define( 'IPB_THIS_SCRIPT', 'public' );
        require_once( $forum_path . '\initdata.php' );

        /**
        * Get IPB registry
        */
        require_once( IPS_ROOT_PATH . 'sources/base/ipsRegistry.php' );
        require_once( IPS_ROOT_PATH . 'sources/base/ipsController.php' );

        /**
         * initialise the ipsRegistry
         */
        $this->ipbRegistry    = ipsRegistry::instance();
        $this->ipbRegistry->init();
    }
    /**
     * logs a user in, username and password should be in $_REQUEST['username'] and $_REQUEST['password']
     */
    public function doLogin()
    {
        /**
         * call the initialisation function
         */
        $this->init();

        /**
         * get the IPB login handler wrapper
         */
        require_once( IPS_ROOT_PATH . 'sources/handlers/han_login.php' );

        /**
         * setup the handler class
         */
        $login  = new han_login( $this->ipbRegistry );
        $login->init();

        /**
         * verify the login and do any necessary tasks. form variables must be called 'username' & 'password'
         */
        $login->verifyLogin();
        
        return $login->return_code;
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
        <head>
                <title><?php echo $_SERVER["HTTP_HOST"] ; ?> :: Log In</title>
                <style type='text/css' media='all'>
                        @import url('http://<?php echo $_SERVER["HTTP_HOST"] ;?>/main.css');
                </style>        
        </head>
        <body><p> </p>
                <form id='install-form' action='index.php?action=login&do=submit' method='post'>
                <input type='hidden' name='_sd' value='b%3A0%3B'>
                <div id='ipswrapper'>
                    <div class='main_shell'>
                            <div id='navigation'>
                                        <ul id='section_buttons'>
                                                <li class='active'><span>Log In</span></li>

                                        </ul>                           </div>
                            <div class='content_shell'>
                                <div class='package'>
                                    <div>                   
                                <div class='content_wrap'>
                <div style='clear:both'></div>      
                                <h2> This Login system is still in the works.</h2>
                                <input type='hidden' name='do' value='login' />
        <br />
          <fieldset>
      <legend>Log In</legend>
                <div id='login_controls'>
                        <label for='username'>Sign In Name</label>
                        <input type='text' size='20' id='username' name='username' value='UserName'>

                        <label for='password'>Password</label>
                        <input type='password' size='20' id='password' name='password' value='PassWord'>      </div>
  </fieldset>
                                        <br />                        <div style='float: right'>                 
                          <input type='submit' class='nav_button' value='Next >' />                     
                                        
 </div>                                                                                         
                                    </div></div></div></div></div></div></form></body></html>

DevFuse - My IP.Board development forums. Read my development blog here.

View My Paid Mods | View My Free Mods | Twitter Updates
0

#5 User is offline   ShaneV 

  • Advanced Member
  • Group: Customers
  • Posts: 48
  • Joined: 16-April 09
  • Gender:Male
  • IP.Board Version:IPB 3.0.x

Posted 08 January 2010 - 12:15 PM

Hi, thanks for the example Michael.
I'm looking for something like this for IPB 2.3 can you help me?
0

#6 User is offline   Michael 

  • Management
  • Group: Management
  • Posts: 2,348
  • Joined: 22-September 05
  • Gender:Male
  • Location:Australia
  • IP.Board Version:IPB 3.0.x
  • First Name:Michael

Posted 09 January 2010 - 04:49 AM

View PostShaneV, on 09 January 2010 - 05:15 AM, said:

Hi, thanks for the example Michael.
I'm looking for something like this for IPB 2.3 can you help me?


I'm not aware of any IPB2.3 files that is similar. IPBWI or IPBSDK would probably be your best choice here.
DevFuse - My IP.Board development forums. Read my development blog here.

View My Paid Mods | View My Free Mods | Twitter Updates
0

#7 User is offline   ShaneV 

  • Advanced Member
  • Group: Customers
  • Posts: 48
  • Joined: 16-April 09
  • Gender:Male
  • IP.Board Version:IPB 3.0.x

Posted 11 January 2010 - 10:18 AM

View PostMichael, on 09 January 2010 - 12:49 PM, said:

I'm not aware of any IPB2.3 files that is similar. IPBWI or IPBSDK would probably be your best choice here.

Thanks for the information :) working fine now.
0

#8 User is offline   MPFF 

  • Elite Member
  • Group: Modders
  • Posts: 127
  • Joined: 28-April 09
  • Gender:Male
  • Location:United Kingdom
  • IP.Board Version:IPB 2.3.x
  • First Name:Dava

Posted 05 February 2010 - 09:53 AM

(MPFF) External Login System v1.0.0 - Released Very soon and intergratable into any page
0

#9 User is offline   ShaneV 

  • Advanced Member
  • Group: Customers
  • Posts: 48
  • Joined: 16-April 09
  • Gender:Male
  • IP.Board Version:IPB 3.0.x

Posted 13 February 2010 - 09:00 AM

Sounds interesting MPFF ;)
Any idea when? Maybe its more usefull to me then IPBSDK.
0

#10 User is offline   MPFF 

  • Elite Member
  • Group: Modders
  • Posts: 127
  • Joined: 28-April 09
  • Gender:Male
  • Location:United Kingdom
  • IP.Board Version:IPB 2.3.x
  • First Name:Dava

Posted 13 February 2010 - 10:15 AM

it will be ready once i finish (MPFF) Virtual Pet System v1.0.0
0

#11 User is offline   ShaneV 

  • Advanced Member
  • Group: Customers
  • Posts: 48
  • Joined: 16-April 09
  • Gender:Male
  • IP.Board Version:IPB 3.0.x

Posted 12 March 2010 - 06:12 PM

@MPFF, any news yet? :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users