session in Dreamweaver and PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cool84
    New Member
    • Mar 2007
    • 5

    session in Dreamweaver and PHP

    neeeed help.

    i want help how to use session in the dreamweaver. I have 2 form. first is the login form and the second is welcome user page. I want the login user page appear at the welcome user page.

    my database sturucture as:

    login(table) user(table)
    ------- ...............
    Uname Account_no
    Upass name ---------------> display in the welcome user page
    Account_no
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    That's fine, however, you have not asked a question. This fact makes it quite difficult for us to answer it.

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Is this a PHP problem or a pure Dreamweaver problem?

      Ronald :cool:

      Comment

      • cool84
        New Member
        • Mar 2007
        • 5

        #4
        use session in php

        Help.... i use dreamweaver and create 3 page.
        1. JConnection.php
        2. Login.php ( use table login1{uname,up ass,matric} )
        3. profile.php ( use table profile1{name,c ourse,faculty,matric}

        i want to use the session , i mean when the user successfully login the system, the user will view their profile page.

        but it is not work. anyone know how 2 some the problwm is !
        [php]

        Jconnection.php

        <?php
        # FileName="Conne ction_php_mysql .htm"
        # Type="MYSQL"
        # HTTP="true"
        $hostname_Jconn ection = "localhost" ;
        $database_Jconn ection = "sample";
        $username_Jconn ection = "root";
        $password_Jconn ection = "";
        $Jconnection = mysql_pconnect( $hostname_Jconn ection, $username_Jconn ection, $password_Jconn ection) or trigger_error(m ysql_error(),E_ USER_ERROR);

        //mysql_select_db ($database_Jcon nection)
        ?>

        Login.php

        <?php
        require_once('C onnections/Jconnection.php ');

        if(isset($_POST['username']))
        {
        $name = $_POST['username'];
        $pass = $_POST['password'];
        $query_Recordse t1 = "select * from login1 where uname = '$name' and upass='$pass'";
        $Recordset1 = mysql_query($qu ery_Recordset1) ;//or die (mysql_error));
        $row_Recordset1 = mysql_fetch_ass oc($Recordset1) ;
        $totalRows_Reco rdset1 = mysql_num_rows( $Recordset1);

        if($totalRows_R ecordset1==1)
        {
        $_SESSION['matric'] = $row_Recordset1['matric'];
        echo $_SESSION['matric'];

        echo '<script>window .location.href= \'profile.php\' </script>';
        }
        }

        ?>

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>Login</title>

        </head>

        <body>
        <form id="form1" name="form1" method="POST" action="login.p hp">

        <table width="405" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FF993 3">
        <tr>
        <th width="405" bgcolor="#3366F F" scope="col"><sp an class="style1"> </span></th>
        </tr>
        <tr>
        <td><p>&nbsp; </p>
        <table width="286" border="0" align="center" cellpadding="0" cellspacing="0" >
        <tr>
        <th width="286" scope="col">use rname
        <label>
        <input name="username" type="text" id="username" />
        <br />
        <br />
        Password
        <input name="password" type="text" id="password" />
        <br />
        <br />
        <input type="submit" name="Submit" value="Submit" />
        <input type="submit" name="Submit2" value="Cancel" />
        </label></th>
        </tr>
        </table>
        </tr>
        <tr>

        </tr>
        </table>

        </form>
        </body>
        </html>


        profile.php

        <?php require_once('C onnections/Jconnection.php '); ?>
        <?php
        $colname_Record set1 = "-1";
        if (isset($_SESSIO N['matric'])) {
        $colname_Record set1 = (get_magic_quot es_gpc()) ? $_SESSION['matric'] : addslashes($_SE SSION['matric']);
        }
        mysql_select_db ($database_Jcon nection, $Jconnection);
        $query_Recordse t1 = sprintf("SELECT * FROM profile1 WHERE matric = '%s'", $colname_Record set1);
        $Recordset1 = mysql_query($qu ery_Recordset1, $Jconnection) or die(mysql_error ());
        $row_Recordset1 = mysql_fetch_ass oc($Recordset1) ;
        $totalRows_Reco rdset1 = mysql_num_rows( $Recordset1);

        //session_start() ;

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>Untitl ed Document</title>
        </head>

        <body>
        <table width="436" border="0" align="center" cellpadding="0" cellspacing="0" >
        <tr>
        <th width="436" bgcolor="#3399F F" scope="col">&nb sp;</th>
        </tr>
        <tr>
        <td bgcolor="#FF993 3"><form id="form1" name="form1" method="post" action="">
        <p></p>
        <table width="374" border="0" align="center" cellpadding="0" cellspacing="0" >
        <tr>
        <th width="328" height="19" scope="col">Nam e
        <label>
        <input name="textfield " type="text" value="<?php echo $row_Recordset1['name']; ?>" />
        <br />
        <br />
        Course
        <input name="textfield 2" type="text" value="<?php echo $row_Recordset1['course']; ?>" />
        <br />
        <br />
        Faculty
        <input name="textfield 3" type="text" value="<?php echo $row_Recordset1['faculty']; ?>" />
        <br />
        <br />
        <input type="submit" name="Submit" value=" OK " />
        <br />
        <br />
        <br />
        </label></th>
        </tr>
        </table>
        </form>
        </td>
        </tr>
        <tr>
        <td bgcolor="#3399F F">&nbsp;</td>
        </tr>
        </table>
        </body>
        </html>
        <?php
        mysql_free_resu lt($Recordset1) ;
        ?>[/php]

        Read the Posting Guidelines before you post any further in this forum!
        Especially the part about enclosing code within code or php tags!!


        You code is absolutely unreadable and can only be read using an IDE (which I will not)

        moderator

        Comment

        • Motoma
          Recognized Expert Specialist
          • Jan 2007
          • 3236

          #5
          You need to call session_start() before you begin to use your session variable.

          Comment

          Working...