PHP Sessions & IU
  • Hello,

    not a PHP developer...

    I already have:
    <?php <br />// Start Session
    if(!session_id()) session_start();

    require_once("include/mysql.php");

    // Check if User is logged in
    if(isset($_SESSION['logged_in']) && $_SESSION['logged_in'] = true){
    header("Location: members/cowgirls-welcome.php");
    exit;
    }


    //if the login form is submitted
    if (isset($_POST['submit_y'])) { // if form has been submitted

    // makes sure they filled it in
    if($_POST['username'] == '' || $_POST['pass'] == '') {
    $_SESSION['message'] = 'Please fill in Username and Password.';
    header("Location: index.php");
    exit;
    }

    // checks it against the database
    $_POST['username'] = mysql_real_escape_string($_POST['username']);


    $check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error());

    //Gives error if user dosen't exist
    $check2 = mysql_num_rows($check);

    if ($check2 == 0)
    {
    $_SESSION['message'] = 'That user does not exist in our database.

    Try again, or Click Here to Register';
    header("Location: index.php");
    exit;
    }

    while($info = mysql_fetch_array( $check ))
    {
    $_POST['pass'] = stripslashes($_POST['pass']);
    $info['password'] = stripslashes($info['password']);

    //gives error if the password is wrong
    if ($_POST['pass'] != $info['password']) {
    $_SESSION['message'] = 'Incorrect password, please try again.';
    header("Location: index.php");
    exit;
    } else if($info['active'] !=1) {
    $_SESSION['message'] = 'Account '.$_POST['username'].' is not active';
    header("Location: index.php");
    exit;
    } else if($info['auth'] != 1){
    $_SESSION['message'] = 'Account '.$_POST['username'].' is not authenticated.';
    header("Location: index.php");
    exit;
    }

    //then redirect them to the members area
    $_SESSION['logged_in'] = true;
    $_SESSION['user_level'] = $info['level'];

    if ($info['level'] == 1){
    header("Location: members/queens-welcome.php");
    exit;
    } else {
    header("Location: members/cowgirls-welcome.php");
    }
    }
    }

    ?>

    where do I add the IU php code? above, below?

    Thanks,

    John
  • Hello,

    I don't know what are you exactly trying to do? If you want to integrate Instant Update to edit your web site you don't need to do anything with this code. This code is used to log in user into something and it always redirects user (if logged in to one, and if credentials are wrong to other page) so it's contents are never displayed to the user, therefore there is no point integrating this script into such page. Instead, you need to integrate pages which are visible to the users, e.g. members/cowgirls-welcome.php, public/membership.php, index.php etc...
  • hi,

    the above site is password protected using "session". All pages on the site have some mention of "session" in their code. I guess my question is whether IU's need for "session" will be impacted or have an impact on the site's existing need for "session". Will both share the same session or conflict? If all is ok, do I put the IU code above or below the existing code? The above page is only seen to non members....the content will need to be editable to site owner.

    I also have a question about changing the editable area on a page. How is this done? Is it possible to lock parts of a page and allow changes only in specific areas? this has to be possible but I have not seen this info in any documentation.

    thank you,

    john
  • Hello,

    It is clearly described where each piece of code needs to be placed (http://www.cubescripts.com/instant-update/wiki/install:converting - please consider reading "Advanced header" part too), but I still stand behind my previous statement that this file should not be converted, but all other pages which contain texts and other content which needs to be edited using WYSIWYG editor.

    As for sessions, this code is good and it should not be in conflict with our code. If it somehow conflicts, tell me what happens and I'll try to help you.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!