leijae Posted June 20, 2011 Share Posted June 20, 2011 I wrote this code: <?php //error_reporting (E_ALL ^ E_NOTICE); $user_name = ""; $pass_word = ""; $database = "members"; $server = ""; //the user/pass if (isset($_POST['Submit1'])) { $username = $_POST['username']; $password = $_POST['password']; $db_handle = mysql_connect($server, $user_name, $pass_word); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "SELECT * FROM signin WHERE username = '$username'"; $SQL1 = "SELECT * FROM signin WHERE password = '$password'"; $result = mysql_query($SQL); $result1 = mysql_query($SQL1); echo "Users: <br />"; while ($db_field = mysql_fetch_assoc($result)) { print $db_field['username'] . "<BR>"; } echo "Passwords: <br />" ; while ($db_field1 = mysql_fetch_assoc($result1)) { print $db_field1['password'] . "<BR>"; } mysql_close($db_handle); } else { print "Database NOT Found "; mysql_close($db_handle); } } ?> it works no problem, but I can't figure out how to replace this form: <div class="signin"> <form NAME ="form1" METHOD ="POST" ACTION ="index.php">Username:<input type="text" name="usernames" /><?php print $usernames; ?> Password:<input class="password" type="password" name="password" /><INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login"></form> </div> with "Welcome, User! Link to comment https://forums.phpfreaks.com/topic/239835-login-and-replacement-text/ Share on other sites More sharing options...
Adam Posted June 20, 2011 Share Posted June 20, 2011 Have a read up on PHP sessions. They'll provide a way for you to preserve the login state between requests. Currently you're just querying a database and printing the results out; on the next request that data is lost. Link to comment https://forums.phpfreaks.com/topic/239835-login-and-replacement-text/#findComment-1232099 Share on other sites More sharing options...
leijae Posted June 27, 2011 Author Share Posted June 27, 2011 yes! thanks that helped me so much! Link to comment https://forums.phpfreaks.com/topic/239835-login-and-replacement-text/#findComment-1235610 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.