Jump to content

A couple of noob questions


Slick Nick

Recommended Posts

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
Link to comment
Share on other sites

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

[code]
// 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.
[/code]
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.