trq Posted April 12, 2007 Share Posted April 12, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/46583-only-selecting-user_name-and-password/page/2/#findComment-227804 Share on other sites More sharing options...
MadTechie Posted April 12, 2007 Share Posted April 12, 2007 quick mod <?php if (isset($_POST['uname'] && isset($_POST['upass'])) { ?> to <?php if ( isset($_POST['uname']) && isset($_POST['upass']) ) { ?> missed the ) on the uname in edit.php Quote Link to comment https://forums.phpfreaks.com/topic/46583-only-selecting-user_name-and-password/page/2/#findComment-227811 Share on other sites More sharing options...
franknu Posted April 12, 2007 Author Share Posted April 12, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/46583-only-selecting-user_name-and-password/page/2/#findComment-227813 Share on other sites More sharing options...
MadTechie Posted April 12, 2007 Share Posted April 12, 2007 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.. Quote Link to comment https://forums.phpfreaks.com/topic/46583-only-selecting-user_name-and-password/page/2/#findComment-227819 Share on other sites More sharing options...
trq Posted April 13, 2007 Share Posted April 13, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/46583-only-selecting-user_name-and-password/page/2/#findComment-228220 Share on other sites More sharing options...
franknu Posted April 13, 2007 Author Share Posted April 13, 2007 for future reference, my biggest problems where some open echos, i found the solutions also my logic wasn't that great thanks to all those who help Quote Link to comment https://forums.phpfreaks.com/topic/46583-only-selecting-user_name-and-password/page/2/#findComment-228509 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.