Jump to content


Photo

A couple of noob questions


  • Please log in to reply
1 reply to this topic

#1 Slick Nick

Slick Nick
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 12 April 2006 - 03:38 AM

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 database

For 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 :S

I think thats it right now. Il make another topic or post here when I have another problem >_>

thanks in advance

#2 sdaniels

sdaniels
  • Members
  • PipPipPip
  • Advanced Member
  • 46 posts

Posted 12 April 2006 - 03:57 AM

Ill answer your first question. Please post your code for your second question.

// if they hit the submit button
if (isset($_POST['Submit'])) {

//connect to the database
include ('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 zero
if ($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.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users