Jump to content

only selecting user_name and password


franknu

Recommended Posts

Ive just about given up on your code so Im just going to explain the logic with some examples. You need 3 files.

 

Firstly, start with a page asking for a username and password.

 

login.php

<form action="edit.php" method="post">
  <input type="text" name="uname">
  <input type="password" name="upass">
  <input type="submit" name="login">
</form>

 

Then, grab all the user details (based on username and pass) and place them in a form.

 

edit.php

<?php

  if (isset($_POST['uname'] && isset($_POST['upass'])) {
    $sql = "SELECT data FROM tbl WHERE uname = '{$_POST['uname']}' && upass = '{$_POST['upass']}'";
    if ($result = mysql_query($sql)) {
      if (mysql_num_rows($sql)) {
        $row = mysql_fetch_assoc($result);
        echo "<form action=\"process_edit.php\" method=\"post\">";
        echo "  <input type=\"text\" name=\"uname\" value=\"{$row['uname']}\">";
        echo "  <input type=\"password\" name=\"upass\" value=\"{$row['upass']}\">";
        echo "  <input type=\"text\" name=\"data\" value=\"{$row['data']}\">";
        echo "  <input type=\"submit\" name=\"login\">";
        echo "</form>";
      }
    }
  }

?>

 

Then, finally, update the infomation into the db.

 

process_edit.php

<?php

  if (isset($_POST['uname']) && isset($_POST['upass']) && isset($_POST['data'])) {
    $sql = "
      UPDATE tbl 
      SET data = '{$_POST['data']}', uname = '{$_POST['uname']}', upass = '{$_POST['upass']}'
      WHERE uname = '{$_POST['uname']}' && upass = '{$_POST['upass']}'";
    if ($result = mysql_query($sql)) {
      echo "uname, upass and data updated";
    }

  }

?>

 

Of course there isn't alot of error handling int hsi code as its just an example of the logic. Sorry, but I just fail to see much logic in your code.

 

Also, if you know what your doing you could impliment all this in one script, its just clearer in multiple scripts.

Link to comment
Share on other sites

ok, thank you, anyways.

 

but let me explain more clear i have the form where the user login. them it log in into this page that i have except that it is a self page which mean i wont create another file to update the page

 

so user typed in info then it take them to a page where he can update and see what is actually on the database, my problem has been that when the user login all the information that is on the database is not showing and it should

 

thank u again

Link to comment
Share on other sites

Advice:

Do what thorpe  as shown..

 

then when it works..

 

build into 1 file..

 

if you read back my first post was asking what your trying to do.. the logic need to be correct, build the system with 3 file and then put into 1

 

or spend a few weeks shooting in the dark..

Link to comment
Share on other sites

my problem has been that when the user login all the information that is on the database is not showing and it should

 

Sorry, but your problem is that you lack logic.

 

Yes, as I said when you know what your doing you can get this all in one file.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.