Jump to content

son.of.the.morning

Members
  • Posts

    292
  • Joined

  • Last visited

    Never

Posts posted by son.of.the.morning

  1. I want kind of work around the code i already have, how would i go about keeping the existing code but modifying to the theory in which you have?

     

    Here is what i have

    checklogin.php

    <?php
    $host="xxxxxxxx"; // Host name 
    $username="xxxxxxxxx"; // Mysql username 
    $password="xxxxxxxx"; // Mysql password 
    $db_name="a2820511_admin"; // Database name 
    $tbl_name="members"; // Table name 
    
    // Connect to server and select databse.
    mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");
    
    // username and password sent from form 
    $myusername=$_POST['myusername']; 
    $mypassword=$_POST['mypassword']; 
    
    // To protect MySQL injection 
    $myusername = stripslashes($myusername);
    $mypassword = stripslashes($mypassword);
    $myusername = mysql_real_escape_string($myusername);
    $mypassword = mysql_real_escape_string($mypassword);
    
    $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
    $result=mysql_query($sql);
    
    // Mysql_num_row is counting table row
    $count=mysql_num_rows($result);
    // If result matched $myusername and $mypassword, table row must be 1 row
    
    if($count==1){
    // Register $myusername, $mypassword and redirect to file "login_success.php"
    session_register("myusername");
    session_register("mypassword"); 
    header("location:login_success.php?id=$myusername");
    }
    else {
    echo "Wrong username or password...";
    }
    ?>

     

    login-success.php

    <? 
    session_start();
    if(!session_is_registered(myusername)){
    header("location:main_login.php");
    }
    $myusername; welcome
    ?>

  2. I am using a login system in php and mySQL but only one page is potected.

     

    pages i am using:

    1. login.php // inputing details (user name, password)

    2. checkloginDetails.php // connect to db and check login details

    3. logged_in.php // successfully login

     

    ...i need more than the one page protected for example; once the user has logged in there will be the main logged in page with other links, remove topics, add, user, remove user all these pages i want protecting but with out the user inputing his details again.

     

    Has anyone got an idear onhow i ould achive this?

     

  3. i cant change the id to x, becuase i am passing a var through it, here is my code

     

     

     

      <?php

    $host="------"; // Host name

    $username="------"; // Mysql username

    $password="------"; // Mysql password

    $db_name="--------"; // Database name

    $tbl_name="forum_question"; // Table name

     

    // Connect to server and select databse.

    mysql_connect("$host", "$username", "$password")or die("cannot connect");

    mysql_select_db("$db_name")or die("cannot select DB");

     

    $id=$_GET['id'];

    ?>

    ><a href="<? mysql_query("DELETE FROM forum_question WHERE id='$id'"); ?>">yes</a></p>

  4. I have finaly got my removing recods page working, but i do have one problem...

     

    i have a delete button which goes to a new php page which contains the DELETE FROM, this deletes the record automaticaly. There are two paths which i could choose from the problem is i am stuck on both of them.

     

    1. a link that will activate the delete code.

    2. once the record has been deleted then it will automaticaly go back the the first page.

     

    can any one help me here please?

  5. Hey again guys,

     

    i am building a site admin page and i want to do a php script with will show the heading and the date of my news database into a table, and on the right or left side of each row i want to put 2 small icons one which will remove the specific record and one which will open a new small window with the whole record viewing.

     

    any idears?

  6. No the insert new record is on a totally different page. I just want to selected the post recently added record.

     

    For example:    if I added a new record to the database and went on the news page  were i am trying to select a record it would show only the last record i inserted.

    Do you understand me?

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.