1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to fix Deprecated: Function session_register() ?

Discussion in 'PHP' started by idev, Mar 12, 2012.

  1. #1
    How can i fix this please

     Deprecated: Function session_register() is deprecated in /index.php on line 3
    Code (markup):
    <?php
    session_start();
    session_register("refid_session");
    foreach($_GET as $k=>$v)
    $id .=$k;
    if($id !="") {
    if($_SESSION["refid_session"]=="") {
    $_SESSION["refid_session"]=$id ;
    }
    }
    include "header.php";
    include "config.php"; 
    
    $rs=mysql_query("select count(*) from users where active=1");
    $arr=mysql_fetch_array($rs);
    $totalusers=$arr[0];
    
    $rs=mysql_query("select * from pages where ID=1");
    $arr=mysql_fetch_array($rs);
    $arr[2]=str_replace("{sitename}",$sitename,$arr[2]);
    $arr[2]=str_replace("{totalinvestment}",$totalinv,$arr[2]);
    $arr[2]=str_replace("{membersearnings}",$memearn,$arr[2]);
    $arr[2]=str_replace("{totalusers}",$totalusers,$arr[2]);
    echo stripslashes($arr[2]);
    
    include "footer.php";
    ?>
    
    PHP:
     
    Solved! View solution.
    idev, Mar 12, 2012 IP
  2. #2
    Use $_SESSION directly to set variables instead of session_register()... If you want your script to work regardless of register_globals, you need to instead use the $_SESSION array as $_SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled. So instead your line with
    
    session_register("refid_session");
    
    PHP:
    I'd use
    
    $_SESSION['session_name'] = 'refid_session';
    
    PHP:
     
    dujmovicv, Mar 13, 2012 IP
  3. idev

    idev Member

    Messages:
    112
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #3
    You are the man, thank you very much.
     
    idev, Mar 13, 2012 IP
  4. dujmovicv

    dujmovicv Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    4
    Trophy Points:
    48
    #4
    No problem pal! Happy to help :)
     
    dujmovicv, Mar 13, 2012 IP
  5. idev

    idev Member

    Messages:
    112
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #5
    Sorry, i have one other problem !
    Deprecated: Function eregi() is deprecated in /join.php on line 52
    Code (markup):
    Lines 47 - 58
    } elseif($_POST[password]!=$_POST[cpassword]) {
    		$cpasswordError = 'Password and Confirm Password doesn\'t match.';
    	}
    	if($_POST['email'] == '') {
    		$emailError = 'You forgot to enter the email address.';
    	} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", $_POST['email'])) {
    		$emailError = 'Enter a valid email address to send to.';
    	}
       if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) {
     	} else {
    $capError="Invalid Security Code.";
        }
    PHP:
     
    idev, Mar 13, 2012 IP
  6. Alex Roxon

    Alex Roxon Active Member

    Messages:
    424
    Likes Received:
    11
    Best Answers:
    7
    Trophy Points:
    80
    #6
    Alex Roxon, Mar 13, 2012 IP
  7. idev

    idev Member

    Messages:
    112
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #7
    Thank you for posting the link, although it does not really help much as im not a PHP coder !
    i don't know how to add/replace "preg_match" into my code ?
     
    idev, Mar 13, 2012 IP
  8. dujmovicv

    dujmovicv Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    4
    Trophy Points:
    48
    #8
    Email validation is not as easy as it seems... It can be done with several good methods. In YOUR case, I would do it like this :
    
    } elseif($_POST[password]!=$_POST[cpassword]) {
            $cpasswordError = 'Password and Confirm Password doesn\'t match.';
        }
        if($_POST['email'] == '') {
            $emailError = 'You forgot to enter the email address.';
        } else {
            $email = $_POST['email'];
            // take a given email address and split it into the  username and domain.
            list($userName, $mailDomain) = split("@", $email);
            if (checkdnsrr($mailDomain, "MX")) {   
              // this is a valid email domain!
            }
            else { 
              // this email domain doesn't exist! 
                  $emailError = 'Enter a valid email address to send to.';
            }       
        }
       if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) {
        } else {
    $capError="Invalid Security Code.";
        }
    
    PHP:
    If the checkdnsrr function returns TRUE, then you know you’ve got a valid email domain (but not necessarily a valid user name). If the function returns FALSE, then the email domain given is invalid. Hope this helps....
     
    dujmovicv, Mar 14, 2012 IP
  9. idev

    idev Member

    Messages:
    112
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #9

    Thank you for your help, although now i get this
    Deprecated: Function split() is deprecated in /join.php on line 55
    Code (markup):
    Lines 49 - 62
        }
        if($_POST['email'] == '') {
            $emailError = 'You forgot to enter the email address.';
        } else {
            $email = $_POST['email'];
            // take a given email address and split it into the  username and domain.
            list($userName, $mailDomain) = split("@", $email);
            if (checkdnsrr($mailDomain, "MX")) {  
              // this is a valid email domain!
            }
            else {
              // this email domain doesn't exist!
                  $emailError = 'Enter a valid email address to send to.';
            }
    PHP:
     
    idev, Mar 14, 2012 IP
  10. dujmovicv

    dujmovicv Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    4
    Trophy Points:
    48
    #10
    hmmmm..... try this, it's working on my server (PHP Version 5.2.17) :
    
    $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*"                 
                  ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*"                 
                  ."\.([a-z]{2,}){1}$";         
             if(!eregi($regex,$email)){            
               // email is NOT valid         
             } else {
               // email IS valid
             }
    
    PHP:
     
    dujmovicv, Mar 14, 2012 IP
  11. Alex Roxon

    Alex Roxon Active Member

    Messages:
    424
    Likes Received:
    11
    Best Answers:
    7
    Trophy Points:
    80
    #11
    Alex Roxon, Mar 14, 2012 IP
  12. dujmovicv

    dujmovicv Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    4
    Trophy Points:
    48
    #12
    dujmovicv, Mar 14, 2012 IP
  13. Alex Roxon

    Alex Roxon Active Member

    Messages:
    424
    Likes Received:
    11
    Best Answers:
    7
    Trophy Points:
    80
    #13
    Both deprecated as of PHP 5.3.
     
    Alex Roxon, Mar 14, 2012 IP