Slick Nick Posted April 12, 2006 Share Posted April 12, 2006 Hey, Im just learning PHP. Im trying to make my third PHP application, but im not sure about a couple things.First of all, how do you check to see if the username and password actually exists in the MySQL database? So far iv got it so that it takes your username and checks if it is in the database, and then displays that usernames password and email that (s)he registerd with (for testing purposes). Problem is though if you put in a non existant username , it just displays "Your password and email are: - -". I need it so that it makes sure that the password and username both exist in the databaseFor my second problem, how would you make it so that when a certian amount of files are read on a page (the fread(); function) then at the bottom of the page there is a link to go to the next page. For example, 5 files are being displayed on the main page. You add another file(max file limit per page is 5) and then php creates a new page, identicle to the main page but with the new files (or old) being displayed instead. Kind of like on a forum when so many people reply and it creates a new page. Sorry if that was confusing, I explained it as best i could :SI think thats it right now. Il make another topic or post here when I have another problem >_>thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/7166-a-couple-of-noob-questions/ Share on other sites More sharing options...
sdaniels Posted April 12, 2006 Share Posted April 12, 2006 Ill answer your first question. Please post your code for your second question.[code]// if they hit the submit buttonif (isset($_POST['Submit'])) {//connect to the databaseinclude ('mysql_connect.php'); //ask for the info from the form$name = $_REQUEST['name'];$password = $_REQUEST['password'];//search for that name and password in a table called security $query = "SELECT * FROM security WHERE user_name = '$name' AND user_password = '$password'";//execute the search$result = @mysql_query($query);//find out if it returned a row that matched your search$num = mysql_num_rows($result);//if the number of rows that it found that DO NOT equal zeroif ($num != 0) {//if it doesnt equal zero then we have a match so do whatever you want here.}//if it does equal zero then we do not have a match so do whatever you want here.[/code] Quote Link to comment https://forums.phpfreaks.com/topic/7166-a-couple-of-noob-questions/#findComment-26078 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.