logo-dw

Go Back   Dreamweaver Club Forums > Dreamweaver forums > Video Tutorials
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 09-03-2007, 03:31 AM   #1
owner
 
Join Date: Sep 2007
Posts: 64
Default Video Tutorial - Login Script #1

Hello,

I am having some troubles with the login script 1st tutorial.

I am not getting any errors, but for some reason, when I hit my submit button, the script cannot find the user that I have in my mySQL database.

Here is the code I am using.

PHP Code:
<?php
require_once("./connection.php"); //Database Connection

//Catch Field Data
$userid     $_POST['userid'];
$password   $_POST['passowrd'];
$submitted  $_POST['submitted'];

if (
$userid && $password) {
/////////////////////////////////////////////
$query      sprintf("SELECT * FROM users where user_name='$userid' and user_password = '$userpassword'");
$result     = @mysql_query($query);
$rowAccount = @mysql_fetch_array($result);
/////////////////////////////////////////////
}

if (
$rowAccount){

echo 
"The record exists so you can enter";

}elseif(
$submitted){

echo 
"You dont exist in the system, so sucks to be you, but your not getting in!";

}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <table width="259" height="172" border="1" align="center">
    <tr> 
      <td width="82" height "45">User ID</td>
      <td width="161"> <input name="userid" type="text" id="userid" /> </td>
    </tr>
    <tr> 
      <td width="82" height "45">Password</td>
      <td width="161"> <input name="password" type="text" id="password" maxlength="26"> </td>
    </tr>
    <tr> 
      <td width="82" height "45">Log Me In Scotty!</td>
      <td width="161"> <div align="center"> 
          <input name="submitted" type="hidden" id="submitted" value="1" />
          <input type="submit" name="submit" value="Login" />
        </div></td>
    </tr>
  </table>
</form>
</body>
</html>
I do have the connection.php file configured right. (I am 99.9% sure )

Also, I do have an account made in the database. I can post a screenshot up of that too, if you need that.

Please help,
Thanks,
-Owner
Attached Images
File Type: jpg db.jpg (36.4 KB, 1 views)
owner is offline   Reply With Quote
Old 09-03-2007, 05:15 AM   #2
owner
 
Join Date: Sep 2007
Posts: 64
Default

Lol, why cant I edit my post

Anyways, Figured it out. If you look closely you will find the error I made too
owner is offline   Reply With Quote
Old 09-03-2007, 08:36 AM   #3
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

nice one

now dont you feel like a right plum when that happens
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 09-03-2007, 02:51 PM   #4
owner
 
Join Date: Sep 2007
Posts: 64
Default Another Question

Yes, I do feel a bit flawed :P

But, I do have another question.

In
Part 9 - Inserting data with PHP


What is the code that is in the php wrappers in the table with the ID1, data2, data3, data4?

Thanks for everything so far!
Your tutorials are awesome!

From my knowledge, it is going to be something like,

<?php echo '$id'; ?>
<?php echo '$data2'; ?>
and so on

am I correct?

Last edited by owner; 09-03-2007 at 02:54 PM..
owner is offline   Reply With Quote
Old 09-03-2007, 02:55 PM   #5
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

i think this is what your after....

PHP Code:
<? echo $rowAccount['db_column']; ?>
Quote:
Your tutorials are awesome!
the ladies think im a bit special as well in a certain department
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 09-03-2007, 02:56 PM   #6
owner
 
Join Date: Sep 2007
Posts: 64
Default

Haha,

and wow that was the fastest reply for help I think i've ever gotten lol
owner is offline   Reply With Quote
Old 09-03-2007, 05:59 PM   #7
owner
 
Join Date: Sep 2007
Posts: 64
Default

Quote:
Originally Posted by davidj View Post
PHP Code:
<? echo $rowAccount['db_column']; ?>
Ok, I tried this, but it only displays the 1st row in the mysql database.

Example: I have 3 id's

1-3 full of information

This is only displaying id #1 information but not 2 and 3. How would I get this to display all of the rows in the database?

EDIT: I forgot to loop it. So here is an example code.

PHP Code:
    <? 
    
do {
    echo 
'<tr><td height="21" valign="top">'.$row['data2'];
    } while (
$row mysql_fetch_array($result));
    echo 
'</td></tr>';
    
?>

Last edited by owner; 09-03-2007 at 06:13 PM..
owner is offline   Reply With Quote
Old 09-04-2007, 08:32 AM   #8
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

so is it working now
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 09-05-2007, 12:47 PM   #9
owner
 
Join Date: Sep 2007
Posts: 64
Default

Yup, flawless!
owner is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:57 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com