Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Help - PHP form Issue

    My Issue: My form will not submit. It will just refresh login.php, whereas it should be posting to login_sub.php
    was handling all the login with login.php, but decided to add that to a different page to further diagnose the problem.

    I really dont understand why it wouldnt submit.

    Im running these and some other functions on a few other pages right now, like inserting into mysql, and those work perfectly fine.


    The code:

    Includes on login.php
    PHP Code:
    <?php include('lib/class_lib.php'); ?>
    <?php
    $session 
    = new funcs();
    $session->session();

    $user_login = new funcs();
    $user_login->login_submit();

    $user_logout = new funcs();
    $user_logout->logout();
    ?>
    My login.php form
    PHP Code:
    <form name="login" action="login_sub.php" method="POST">
    <
    label>Username:</label>
    <
    input name="uname" type="text" />
    <
    br /><br />
    <
    label>Password:</label>
    <
    input name="pword" type="password" />
    <
    br /><br />
    <
    input name="submit" value="Log In" type="submit" />
    </
    form
    the called functions. login_submit() is irrelivent atm because I have replaced calling that variable with just a straight forward action
    PHP Code:
    function session() {
            if (!isset(
    $_SESSION)) {
                  
    session_start();
            }    
        }
    function 
    logout() {
            
    // ** Logout the current user. **
            
    $this->logout_link $_SERVER['PHP_SELF']."?doLogout=true";
            if ((isset(
    $_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
                  
    $this->logout_link .="&"htmlentities($_SERVER['QUERY_STRING']);
            }

            if ((isset(
    $_GET['doLogout'])) &&($_GET['doLogout']=="true")){
                 
    //to fully log out a visitor we need to clear the session varialbles
                  
    $_SESSION['MM_Username'] = NULL;
                  
    $_SESSION['MM_UserGroup'] = NULL;
                  
    $_SESSION['PrevUrl'] = NULL;
                 unset(
    $_SESSION['MM_Username']);
                  unset(
    $_SESSION['MM_UserGroup']);
                  unset(
    $_SESSION['PrevUrl']);
        
                  
    $this->logout_direct "login.php";
                  if (
    $this->logout_direct) {
                    
    header("Location: $this->logout_direct");
                   exit;
                  }
            }
        } 
    Last edited by vilify; 01-15-2012 at 12:46 AM.

  • #2
    12k
    12k is offline
    New Coder
    Join Date
    Jan 2012
    Posts
    29
    Thanks
    0
    Thanked 6 Times in 6 Posts
    I see no reason you shouldn't atleast be getting directed to the login_sub.php page. Try to make sure for some odd reason it isnt stored into your browsers cache or something odd. Visit the page and before you submit a form, view the html source code using your browser, and make sure the action is set to action="login_sub.php".

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Change this
    PHP Code:
    function logout() {
            
    // ** Logout the current user. **
            
    $this->logout_link $_SERVER['PHP_SELF']."?doLogout=true";
            if ((isset(
    $_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
                  
    $this->logout_link .="&"htmlentities($_SERVER['QUERY_STRING']);
            }

            if ((isset(
    $_GET['doLogout'])) &&($_GET['doLogout']=="true")){
                 
    //to fully log out a visitor we need to clear the session varialbles
                  
    $_SESSION['MM_Username'] = NULL;
                  
    $_SESSION['MM_UserGroup'] = NULL;
                  
    $_SESSION['PrevUrl'] = NULL;
                 unset(
    $_SESSION['MM_Username']);
                  unset(
    $_SESSION['MM_UserGroup']);
                  unset(
    $_SESSION['PrevUrl']);
        
                  
    $this->logout_direct "login.php";
                  if (
    $this->logout_direct) {
                    
    header("Location: $this->logout_direct");
                   exit;
                  }
            }
        } 
    to this
    PHP Code:
    function logout() {
            
    // ** Logout the current user. **
            
    $this->logout_link $_SERVER['PHP_SELF']."?doLogout=true";
            if ((isset(
    $_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
                  
    $this->logout_link .="&"htmlentities($_SERVER['QUERY_STRING']);
            }

            if ((isset(
    $_GET['doLogout'])) &&($_GET['doLogout']=="true")){
                 
    //to fully log out a visitor we need to clear the session varialbles
                  
    $_SESSION['MM_Username'] = NULL;
                  
    $_SESSION['MM_UserGroup'] = NULL;
                  
    $_SESSION['PrevUrl'] = NULL;
                 unset(
    $_SESSION['MM_Username']);
                  unset(
    $_SESSION['MM_UserGroup']);
                  unset(
    $_SESSION['PrevUrl']);
        echo 
    'got here.';
    exit();
                  
    $this->logout_direct "login.php";
                  if (
    $this->logout_direct) {
                    
    header("Location: $this->logout_direct");
                   exit;
                  }
            }
        } 
    And post your results. If you go the words "got here" then your logout function is redirecting to login.php because it thinks doLogout is set some how.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    Change this
    And post your results. If you go the words "got here" then your logout function is redirecting to login.php because it thinks doLogout is set some how.
    Changed what you said, even tried commenting out the code that calls the functions. No results. Still refreshes.

    Going to rewrite a new simple login.php with no php and see what it does.

  • #5
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    May have found the issue, but I'm tired, and cant figure it out lol.. also a bit new to classes and functions.

    getting: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given

    PHP Code:
    function login($post_user$post_pass) {
            if (isset(
    $_POST['uname'])) {
                  
    $this->login_user $post_user;
                  
    $this->login_pass $post_pass;
                  
    $this->userAuthorization "";
                  
    $this->direct_success "index.php";
                  
    $this->direct_fail "";
                  
    $this->direct_refer false;    
                
                
    $this->login_rs "SELECT username, password FROM users WHERE username='$this->login_user' AND password='$this->login_pass'"
       
                  
    $this->login_query mysql_query($this->login_rs);
                  
    $this->found_user mysql_num_rows($this->login_query);
                  if (
    $this->found_user) {
                     
    $this->user_group "";
        
                    if (
    PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
                        
    //declare two session variables and assign them
                        
    $_SESSION['MM_Username'] = '$this->login_user';
                        
    $_SESSION['MM_UserGroup'] = '$this->user_group';          

                    if (isset(
    $_SESSION['PrevUrl']) && false) {
                          
    $this->direct_success $_SESSION['PrevUrl'];    
                    }
                    
    header("Location: " $this->direct_success );
                  }
                 else {
                    
    header("Location: "$this->direct_fail );
                  }
            }
        } 

  • #6
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Added a few echo codes to see where it was getting.

    It is getting the user information, login_rs gets set properly, but getting a blank output from login_query.

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    So something may be happening with your query. Change this
    PHP Code:
                $this->login_rs "SELECT username, password FROM users WHERE username='$this->login_user' AND password='$this->login_pass'"
       
                  
    $this->login_query mysql_query($this->login_rs); 
    to this
    PHP Code:
                $this->login_rs "SELECT username, password FROM users WHERE username='$this->login_user' AND password='$this->login_pass'"
       
                  
    $this->login_query mysql_query($this->login_rs) or die(mysql_error().'<br>'.$this->login_rs
    Post your results. My guess is your query might be failing.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #8
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    So something may be happening with your query. Change this
    PHP Code:
                $this->login_rs "SELECT username, password FROM users WHERE username='$this->login_user' AND password='$this->login_pass'"
       
                  
    $this->login_query mysql_query($this->login_rs); 
    to this
    PHP Code:
                $this->login_rs "SELECT username, password FROM users WHERE username='$this->login_user' AND password='$this->login_pass'"
       
                  
    $this->login_query mysql_query($this->login_rs) or die(mysql_error().'<br>'.$this->login_rs
    Post your results. My guess is your query might be failing.
    Good call. No database selected.
    correctly echoes login_rs below that.

    variable declared in class. var $db = "grow";
    PHP Code:
    function db_connect() {
            
    //Connect to
            
    $this->db_connect or die(mysql_error());
            
    mysql_select_db($this->db);    
        } 
    found that i wasnt calling db_connect, so I did that a few different ways, but its still not working. same error.
    Last edited by vilify; 01-15-2012 at 02:24 AM.

  • #9
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Can you post your db_connect function removing your sensitive information of course. Posting your entire class might help as well.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #10
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php
    //DB Class
    class funcs {
        
    //Variables
        
    var $db_connect "mysql_connect('localhost', 'user', 'pass')";
        var 
    $db_select "mysql_select_db('dbname')";
        var 
    $dbtable;
        var 
    $theValue;
        var 
    $theType;
        var 
    $theDefinedValue;
        var 
    $login_action;
        var 
    $login_user;
        var 
    $login_pass;
        var 
    $userAuthorization;
        var 
    $direct_success;
        var 
    $direct_fail;
        var 
    $direct_refer;
        var 
    $login_rs;
        var 
    $login_query;
        var 
    $found_user;
        var 
    $user_group;
        var 
    $logout_link;
        var 
    $logout_direct;
        var 
    $uname;
        var 
    $upass;
        var 
    $uemail;
        var 
    $userid;
        var 
    $plant_strain;
        var 
    $plant_stage;
        var 
    $plant_num;
        var 
    $plant_month;
        var 
    $plant_day;
        var 
    $plant_year;
        var 
    $plant_flower;
        
    //Start Session
        
    function session() {
            if (!isset(
    $_SESSION)) {
                  
    session_start();
            }    
        }
        
    //Connect DB
        
    function db_connect() {
            
    //Connect to
            
    $this->db_connect or die(mysql_error());
            
    $this->db_select;    
        }

        
    //Insert User
        
    function insert_user($table$user$pass$email) {
            
    //Insert
            
    $this->dbtable $table;
            
    $this->uname $user;
            
    $this->upass $pass;
            
    $this->uemail $email;
            
    mysql_query("INSERT INTO $this->dbtable (id, username, password, email) VALUES ('NULL', '$this->uname', '$this->upass', '$this->uemail')");
        }
        
    //Insert Plant
        
    function insert_plant($table$uid$p_strain$p_stage$p_num$p_month$p_day$p_year$p_flower) {
            
    //Insert
            
    $this->dbtable $table;
            
    $this->userid $uid;
            
    $this->plant_strain $p_strain;
            
    $this->plant_stage $p_stage;
            
    $this->plant_num $p_num;
            
    $this->plant_month $p_month;
            
    $this->plant_day $p_day;
            
    $this->plant_year $p_year;
            
    $this->plant_flower $p_flower;
            
    mysql_query("INSERT INTO $this->dbtable (id, uid, strain, stage, p_num, month, day, year, flower) VALUES ('NULL', '$this->userid', '$this->plant_strain', '$this->plant_stage', '$this->plant_num', '$this->plant_month', '$this->plant_day', '$this->plant_year', '$this->plant_flower')");
        }
        
    //Login Link
        
    function login_submit() {
            
    $this->login_action $_SERVER['PHP_SELF'];
        }
        
    //Login User
        
    function login($post_user$post_pass) {
            if (isset(
    $_POST['uname'])) {
                  
    $this->login_user $post_user;
                  
    $this->login_pass $post_pass;
                  
    $this->userAuthorization "";
                  
    $this->direct_success "index.php";
                  
    $this->direct_fail "";
                  
    $this->direct_refer false;    
                
                
    $this->login_rs "SELECT username, password FROM users WHERE username='$this->login_user' AND password='$this->login_pass'"
                
                  
    $this->login_query mysql_query($this->login_rs) or die(mysql_error().'<br>'.$this->login_rs);
                  
    $this->found_user mysql_num_rows($this->login_query);
                  if (
    $this->found_user) {
                     
    $this->user_group "";
        
                    if (
    PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
                        
    //declare two session variables and assign them
                        
    $_SESSION['MM_Username'] = '$this->login_user';
                        
    $_SESSION['MM_UserGroup'] = '$this->user_group';          

                    if (isset(
    $_SESSION['PrevUrl']) && false) {
                          
    $this->direct_success $_SESSION['PrevUrl'];    
                    }
                    
    header("Location: " $this->direct_success );
                  }
                 else {
                    
    header("Location: "$this->direct_fail );
                  }
            }
        }
        
    //Logout User
        
    function logout() {
            
    // ** Logout the current user. **
            
    $this->logout_link $_SERVER['PHP_SELF']."?doLogout=true";
            if ((isset(
    $_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
                  
    $this->logout_link .="&"htmlentities($_SERVER['QUERY_STRING']);
            }

            if ((isset(
    $_GET['doLogout'])) &&($_GET['doLogout']=="true")){
                 
    //to fully log out a visitor we need to clear the session varialbles
                
    $_SESSION['uid'] = NULL;
                  
    $_SESSION['MM_Username'] = NULL;
                  
    $_SESSION['MM_UserGroup'] = NULL;
                  
    $_SESSION['PrevUrl'] = NULL;
                unset(
    $_SESSION['uid']);
                 unset(
    $_SESSION['MM_Username']);
                  unset(
    $_SESSION['MM_UserGroup']);
                  unset(
    $_SESSION['PrevUrl']);
        
                  
    $this->logout_direct "login.php";
                  if (
    $this->logout_direct) {
                    
    header("Location: $this->logout_direct");
                   exit;
                  }
            }
        }
        
    //New Function
        
    function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue "") {
              if (
    PHP_VERSION 6) {
            
    $this->theValue get_magic_quotes_gpc() ? stripslashes($this->theValue) : $this->theValue;
              }

              
    $this->theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($this->theValue) : mysql_escape_string($this->theValue);

              switch (
    $this->theType) {
                case 
    "text":
                 
    $this->theValue = ($this->theValue != "") ? "'" $this->theValue "'" "NULL";
                  break;    
                case 
    "long":
                case 
    "int":
                  
    $this->theValue = ($this->theValue != "") ? intval($this->theValue) : "NULL";
                  break;
                case 
    "double":
                  
    $this->theValue = ($this->theValue != "") ? doubleval($this->theValue) : "NULL";
                  break;
                    case 
    "date":
                  
    $this->theValue = ($this->theValue != "") ? "'" $this->theValue "'" "NULL";
                  break;
                case 
    "defined":
                  
    $this->theValue = ($this->theValue != "") ? $this->theDefinedValue $this->theNotDefinedValue;
                  break;
              }
              return 
    $this->theValue;
            }
    //End Class        
    }

    ?>

  • #11
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Quote Originally Posted by vilify View Post
    PHP Code:
    <?php
    //DB Class
    class funcs {
        
    //Variables
        
    var $db_connect "mysql_connect('localhost', 'user', 'pass')";
        var 
    $db_select "mysql_select_db('dbname')";
        var 
    $dbtable;
        var 
    $theValue;
        var 
    $theType;
        var 
    $theDefinedValue;
        var 
    $login_action;
        var 
    $login_user;
        var 
    $login_pass;
        var 
    $userAuthorization;
        var 
    $direct_success;
        var 
    $direct_fail;
        var 
    $direct_refer;
        var 
    $login_rs;
        var 
    $login_query;
        var 
    $found_user;
        var 
    $user_group;
        var 
    $logout_link;
        var 
    $logout_direct;
        var 
    $uname;
        var 
    $upass;
        var 
    $uemail;
        var 
    $userid;
        var 
    $plant_strain;
        var 
    $plant_stage;
        var 
    $plant_num;
        var 
    $plant_month;
        var 
    $plant_day;
        var 
    $plant_year;
        var 
    $plant_flower;
        
    //Start Session
        
    function session() {
            if (!isset(
    $_SESSION)) {
                  
    session_start();
            }    
        }
        
    //Connect DB
        
    function db_connect() {
            
    //Connect to
            
    $this->db_connect or die(mysql_error());
            
    $this->db_select;    
        }

        
    //Insert User
        
    function insert_user($table$user$pass$email) {
            
    //Insert
            
    $this->dbtable $table;
            
    $this->uname $user;
            
    $this->upass $pass;
            
    $this->uemail $email;
            
    mysql_query("INSERT INTO $this->dbtable (id, username, password, email) VALUES ('NULL', '$this->uname', '$this->upass', '$this->uemail')");
        }
        
    //Insert Plant
        
    function insert_plant($table$uid$p_strain$p_stage$p_num$p_month$p_day$p_year$p_flower) {
            
    //Insert
            
    $this->dbtable $table;
            
    $this->userid $uid;
            
    $this->plant_strain $p_strain;
            
    $this->plant_stage $p_stage;
            
    $this->plant_num $p_num;
            
    $this->plant_month $p_month;
            
    $this->plant_day $p_day;
            
    $this->plant_year $p_year;
            
    $this->plant_flower $p_flower;
            
    mysql_query("INSERT INTO $this->dbtable (id, uid, strain, stage, p_num, month, day, year, flower) VALUES ('NULL', '$this->userid', '$this->plant_strain', '$this->plant_stage', '$this->plant_num', '$this->plant_month', '$this->plant_day', '$this->plant_year', '$this->plant_flower')");
        }
        
    //Login Link
        
    function login_submit() {
            
    $this->login_action $_SERVER['PHP_SELF'];
        }
        
    //Login User
        
    function login($post_user$post_pass) {
            if (isset(
    $_POST['uname'])) {
                  
    $this->login_user $post_user;
                  
    $this->login_pass $post_pass;
                  
    $this->userAuthorization "";
                  
    $this->direct_success "index.php";
                  
    $this->direct_fail "";
                  
    $this->direct_refer false;    
                
                
    $this->login_rs "SELECT username, password FROM users WHERE username='$this->login_user' AND password='$this->login_pass'"
                
                  
    $this->login_query mysql_query($this->login_rs) or die(mysql_error().'<br>'.$this->login_rs);
                  
    $this->found_user mysql_num_rows($this->login_query);
                  if (
    $this->found_user) {
                     
    $this->user_group "";
        
                    if (
    PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
                        
    //declare two session variables and assign them
                        
    $_SESSION['MM_Username'] = '$this->login_user';
                        
    $_SESSION['MM_UserGroup'] = '$this->user_group';          

                    if (isset(
    $_SESSION['PrevUrl']) && false) {
                          
    $this->direct_success $_SESSION['PrevUrl'];    
                    }
                    
    header("Location: " $this->direct_success );
                  }
                 else {
                    
    header("Location: "$this->direct_fail );
                  }
            }
        }
        
    //Logout User
        
    function logout() {
            
    // ** Logout the current user. **
            
    $this->logout_link $_SERVER['PHP_SELF']."?doLogout=true";
            if ((isset(
    $_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
                  
    $this->logout_link .="&"htmlentities($_SERVER['QUERY_STRING']);
            }

            if ((isset(
    $_GET['doLogout'])) &&($_GET['doLogout']=="true")){
                 
    //to fully log out a visitor we need to clear the session varialbles
                
    $_SESSION['uid'] = NULL;
                  
    $_SESSION['MM_Username'] = NULL;
                  
    $_SESSION['MM_UserGroup'] = NULL;
                  
    $_SESSION['PrevUrl'] = NULL;
                unset(
    $_SESSION['uid']);
                 unset(
    $_SESSION['MM_Username']);
                  unset(
    $_SESSION['MM_UserGroup']);
                  unset(
    $_SESSION['PrevUrl']);
        
                  
    $this->logout_direct "login.php";
                  if (
    $this->logout_direct) {
                    
    header("Location: $this->logout_direct");
                   exit;
                  }
            }
        }
        
    //New Function
        
    function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue "") {
              if (
    PHP_VERSION 6) {
            
    $this->theValue get_magic_quotes_gpc() ? stripslashes($this->theValue) : $this->theValue;
              }

              
    $this->theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($this->theValue) : mysql_escape_string($this->theValue);

              switch (
    $this->theType) {
                case 
    "text":
                 
    $this->theValue = ($this->theValue != "") ? "'" $this->theValue "'" "NULL";
                  break;    
                case 
    "long":
                case 
    "int":
                  
    $this->theValue = ($this->theValue != "") ? intval($this->theValue) : "NULL";
                  break;
                case 
    "double":
                  
    $this->theValue = ($this->theValue != "") ? doubleval($this->theValue) : "NULL";
                  break;
                    case 
    "date":
                  
    $this->theValue = ($this->theValue != "") ? "'" $this->theValue "'" "NULL";
                  break;
                case 
    "defined":
                  
    $this->theValue = ($this->theValue != "") ? $this->theDefinedValue $this->theNotDefinedValue;
                  break;
              }
              return 
    $this->theValue;
            }
    //End Class        
    }

    ?>
    I would separate out your classes. Seems you're trying to combine everything into one class, rather than split the logic. I would have a think about more specific classes (like a user class, a database class) and take it from there. It makes everything so much more modular, and easier to understand. It also helps you for the future - you can carry all the more specific, modular classes over to future projects.

    For a database class, I would make use of the constructor magic method like this:
    PHP Code:
    class db {

        
    // Think about variable scope as well. By making a variable private, it can only be accessed by instances of this class.
        // If you plan on extending this class with another class, you can change the scope to protected to allow access through the extended instance.
        
    private $connection;

        
    __construct($host,$user,$pass,$database){
            
    $this->connection mysql_connect($host,$user,$pass);
            if(
    $this->connection != FALSE){
                
    $db mysql_select_db($host,$this->connection);
                if(!
    $db){
                    
    // Some more error reporting
                
    }
            }
            else{
                
    // Do some error reporting - exceptions maybe
            
    }
        }

    }

    // Defining a class like that, means you can do this
    // Could use try and catch for error reporting, if exceptions used (recommended)
    $db = new db('localhost','user','pass','foo'); 
    However, for your particular class - you have a variable called db_connect, and a method called db_connect. I'm not sure now PHP would react to that (obviously it's ok just redefining it). Take your connect function out of the variable, and just put it in the method in a fashion similar to the construct method I posted above - means you can do some real error reporting on mysql_connect.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • Users who have thanked BluePanther for this post:

    vilify (01-15-2012)

  • #12
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    omg thank you . your way works perfect! +rep +thanks

    I am fairly new to classes/functions. Just going off what I learned on killerphp

    suggestions on anywhere to help me better understand some OOP?
    Last edited by vilify; 01-15-2012 at 08:39 AM.

  • #13
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Thanks, glad I could help

    The PHP manual is a great resource. It has definitions of every function and datatype available in PHP. They have a decent explanation of their classes and objects in there too.

    It's just about thinking about OOP logically. Objects should represent different areas and group related tasks together. If you think about it in real world scenarios, your toaster (object) can cook bread, but shouldn't cook beans. Your hob (object) can cook beans, but shouldn't toast bread. But, your toaster and hob can be used to make beans on toast
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •