SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Welcome note

  1. #1
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Welcome note

    Hi all.

    I have been trying to do the Welcome ...name.... on my pages but failed I realy dont get what I am doing wrong as I have two login pages the html and the php page which the html from I refere to.

    Any idea on what I can do to get past through this.

    Thanks in advance.

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2006
    Location
    Closer than you think
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you show your code from those pages and your Database Layout? I don't think you've provided enough information for anyone to be able to help you.

  3. #3
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    //this is the index.html


    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Procurement Tracking System</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body><table width="100&#37;" border="0">
      <tr>
        <td><img src="../Procurement/procurement.JPG"></td>
      </tr>
    </table>
    <form action="login.php" method="post" name="Form"> 
    <hr color="#000000">
    <p></p><div align="center">
    <table width="44%" border="0" bordercolordark="#333333" bgcolor="#CACAFF" bordercolorlight="#000000">
      <tr>
        <td colspan="2" valign="top" bgcolor="#CACAFF"><div align="center"><b>PLEASE LOG-IN</b></div></td>
        
      </tr>
      <tr>
          <td width="31%" valign="top" align="left"><strong>Username</strong></td>
        <td width="69%" valign="top" align="left"><input type="text" name="username" maxlength="40"></td>
      </tr>
      <tr>
          <td valign="top" align="left"><strong>Password</strong></td>
        <td valign="top" align="left"><input type="password" name="password" maxlength="50"></td>
      </tr>
      <tr>
        <td colspan="2" valign="top" align="center"><input type="submit" name="submit" value="Login" onclick ="return alertSearch()">
        
      </tr>
    </table>
        <p><a href="fogot_pw.php">Fogotten Password?</a></p>
    
    <table width="44%" >
     
      
    </table>
    
    </div>
    <p></p>
    <hr color="#000000">
    </form> 
    
    <form action="regOfficer.html" method="post"  form="regForm">
    <strong><font color="#000000" size="2">Click here to Register &nbsp;</font></strong><input type="submit" name="register" value="New Officer &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;">
    </form>
    <form action="addSupp.html" method="post"  form="regForm">
    <strong><font color="#000000" size="2">Click here to Register &nbsp;</font></strong><input type="submit" name="register" value="New Supplier &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;">
    </form>
    <script language="JavaScript" type ="text/javascript">
    		
    function alertSearch(){
    			
    		if(document.Form.username.value == ""){
    			alert("Please enter username");
    			document.Form.username.focus();
    			return false;
    		}
    
    		if(document.Form.password.value == ""){
    			alert("Please enter password");
    			document.Form.password.focus();
    			return false;
    		}	
    }
    
    </script>
    </body>
    </html>
    //this is the php code my login.php

    PHP Code:
    <?

       $connection 
    mysql_connect("localhost""root""issasql");
       
    $select_db mysql_select_db("procdumy"$connection);
       
    $query mysql_query ("SELECT username,password,user_id FROM user_info where user_id ='".$_SESSION["user_id"]."'"$connection);

        if(isset(
    $_COOKIE['ID_my_site'])){ 
        

            
    $name $_COOKIE['ID_my_site']; 
            
    $pass $_COOKIE['Key_my_site'];
            
    $check mysql_query("SELECT username,password,user_id FROM user_info WHERE user_id = '$username'")or die(mysql_error());
            
    //$check = mysql_query("SELECT cust_username,cust_pswrd FROM customer WHERE cust_username = '$cust_username'")or die(mysql_error());
            
    while($info mysql_fetch_array$check )) 
            {
                if (
    $pass != $info['password']) 
                {
                } else {
                    
    header("Location: search_user.php");            
                    
    //header("Location: welcome.php");
                
    }
            }
        }

        if (isset(
    $_POST['submit'])) { 
            if(!
    $_POST['username'] || !$_POST['password']) {
            
    //die('You did not fill in a required field.<a href=index.html>back</a>');
            
    header("Location: Fail.html");
            
    //die('href=loginFail.html');
        
    }
        
        if (!
    get_magic_quotes_gpc()) {
            
    $_POST['email'] = ($_POST['email']);
            
    $_POST['email'] = addslashes($_POST['email']);
        }
        
        
    $check mysql_query("SELECT username, password, status FROM user_info WHERE username = '".$_POST['username']."'")or die(mysql_error());
        
        
    //Gives error if user dosen't exist
        
    $check2 mysql_num_rows($check);
        if (
    $check2 == 0) {
            
    header("Location: loginFail1.html");
            
    //die('That user does not exist in our database.     <a href=index.html>Click Here to Register</a>');
        
    } else {
        
            while(list(
    $username$password$status) = mysql_fetch_array$check )) 
            {
                
    $_POST['password'] = stripslashes($_POST['password']);
                
    $password stripslashes($password);
                
    $_POST['password'] = md5($_POST['password']);
        
                if (
    $_POST['password']!= $password) {
                        
    header("Location: loginFail2.html");
                        
    //die('Incorrect password, please try again.<a href=index.html>Click Here </a>');
                
    } else     { 
        
                        if (
    $status == '1'){ 
            
                            
    $_POST['username'] = stripslashes($_POST['username']); 
                            
    $hour time() + 3600
                            
    //header("Location: viewProduct.html");
                        
    header("Location: viewProduct1.php");
                        
                        } else if (
    $status == '2') {
                        
            
                            
    $_POST['username'] = stripslashes($_POST['username']); 
                            
    $hour time() + 3600
                            
    //header("Location: search_user.php");                        
                            //header("Location: viewSupp.php");
                            
    header("Location: welcome.php");                    
                        
                        }
                }
            }
        
    //}
        
    }}

    ?>
    // the database srtucture

    +-------------+-----------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +-------------+-----------------+------+-----+---------+----------------+
    | user_id | int(7) unsigned | | PRI | NULL | auto_increment |
    | username | varchar(30) | YES | | NULL | |
    | password | varchar(45) | YES | | NULL | |
    | status | char(1) | YES | | NULL | |
    | name | varchar(20) | YES | | NULL | |
    | surname | varchar(25) | YES | | NULL | |
    | persal_num | int(9) | YES | | NULL | |
    | tele | varchar(15) | YES | | NULL | |
    | fax | varchar(15) | YES | | NULL | |
    | email | varchar(30) | YES | | NULL | |
    | supp_name | varchar(50) | YES | | NULL | |
    | buss_addr | varchar(150) | YES | | NULL | |
    | pos_addr | varchar(150) | YES | | NULL | |
    | type | varchar(20) | YES | | NULL | |
    | description | varchar(35) | YES | | NULL | |
    | reg_num | varchar(15) | YES | | NULL | |
    | vat_num | varchar(15) | YES | | NULL | |
    | cr_smme_num | int(15) | YES | | NULL | |
    | id_num | int(13) | YES | | NULL | |

  4. #4
    SitePoint Zealot
    Join Date
    Jul 2006
    Location
    Closer than you think
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you want to display the UserName or the Name? I will assume you are trying to display the name.

    PHP Code:
    <?

       $connection 
    mysql_connect("localhost""root""issasql");
       
    $select_db mysql_select_db("procdumy"$connection);
       
    $query mysql_query ("SELECT username,password,user_id FROM user_info where user_id ='".$_SESSION["user_id"]."'"$connection);

        if(isset(
    $_COOKIE['ID_my_site'])){
        

            
    $name $_COOKIE['ID_my_site'];
            
    $pass $_COOKIE['Key_my_site'];
            
    $check mysql_query("SELECT username,password,user_id FROM user_info WHERE user_id = '$username'")or die(mysql_error());
            
    //$check = mysql_query("SELECT cust_username,cust_pswrd FROM customer WHERE cust_username = '$cust_username'")or die(mysql_error());
            
    while($info mysql_fetch_array$check ))
            {
                if (
    $pass != $info['password'])
                {
                } else {
                    
    header("Location: search_user.php");            
                    
    //header("Location: welcome.php");
                
    }
            }
        }

        if (isset(
    $_POST['submit'])) {
            if(!
    $_POST['username'] || !$_POST['password']) {
            
    //die('You did not fill in a required field.<a href=index.html>back</a>');
            
    header("Location: Fail.html");
            
    //die('href=loginFail.html');
        
    }
        
        if (!
    get_magic_quotes_gpc()) {
            
    $_POST['email'] = ($_POST['email']);
            
    $_POST['email'] = addslashes($_POST['email']);
        }
        
        
    $check mysql_query("SELECT username, password, name, status FROM user_info WHERE username = '".$_POST['username']."'")or die(mysql_error());
        
        
    //Gives error if user dosen't exist
        
    $check2 mysql_num_rows($check);
        if (
    $check2 == 0) {
            
    header("Location: loginFail1.html");
            
    //die('That user does not exist in our database.     <a href=index.html>Click Here to Register</a>');
        
    } else {
        
            while(list(
    $username$password$name$status) = mysql_fetch_array$check ))
            {
                
    $_POST['password'] = stripslashes($_POST['password']);
                
    $password stripslashes($password);
                
    $_POST['password'] = md5($_POST['password']);
        
                if (
    $_POST['password']!= $password) {
                        
    header("Location: loginFail2.html");
                        
    //die('Incorrect password, please try again.<a href=index.html>Click Here </a>');
                
    } else     {
        
                        if (
    $status == '1'){
            
                            
    $_POST['username'] = stripslashes($_POST['username']);
                            
    $hour time() + 3600;
                            
    setcookie("Name"$name);
                            
    //header("Location: viewProduct.html");
                        
    header("Location: viewProduct1.php");
                        
                        } else if (
    $status == '2') {
                        
            
                            
    $_POST['username'] = stripslashes($_POST['username']);
                            
    $hour time() + 3600;
                            
    setcookie("Name"$name);
                            
    //header("Location: search_user.php");                        
                            //header("Location: viewSupp.php");
                            
    header("Location: welcome.php");                    
                        
                        }
                }
            }
        
    //}
        
    }}

    ?>
    When you want to Print the Name simply use

    PHP Code:
    echo $_COOKIE["Name"]; 
    Hope that helps

  5. #5
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah it works! finally


    Thanx a lot.


Bookmarks

Posting Permissions

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