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 04-23-2009, 06:01 AM   #1
drakecai
 
Join Date: Apr 2009
Posts: 10
Default Davids Login Tutorial

I followed all of David's steps and here is the code I ended with

Code:
<?php
require_once("Connections/connection.php");

// catch field data
$userid = $_POST['userid');
$password = $_POST['password');
$submitted = $_POST['submitted');

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

if ($rowAccount){

echo "LegacyZ is currently in construction, please check back later.";

}elseif($submitted){

echo "Sorry, you have not signed 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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <table width="311" border="1" align="center">
    <tr>
      <th width="92" scope="col">Username:</th>
      <th width="203" scope="col"><input type="text" name="userid" id="userid" /></th>
    </tr>
    <tr>
      <th scope="col">Password:</th>
      <th scope="col"><input type="text" name="password" id="password" /></th>
    </tr>
    <tr>
      <th scope="col">&nbsp;</th>
      <th scope="col"><p>&nbsp;
        </p>
        <p>
          <input name="submitted" type="hidden" id="submitted" value="1" />
          <input type="submit" name="button" id="button" value="Submit" />
        </p>
      <p>&nbsp;</p></th>
    </tr>
  </table>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</form>
</body>
</html>


I think its all right, I have this as my connection,php

Code:
<?php
///////////////////////////////////
@database = "localhost";
@username = "root";
@password = "";
//////////////////////////////////

@link = @mysql_connect('localhost', $username, $password);
@db = mysql_select_db($database, $link);

?>
With all that I got this error after typing in random information into the login and password box

Code:
File Not Found

      

      
      
      

      
        
        

          

Firefox can't find the file at /C:/Documents and Settings/Drake Cai/Desktop/LegacyZ/Website/<?php $_SERVER['PHP_SELF'];?>.

        


        
        

    * Could the item have been renamed, removed, or relocated?
    * Is there a spelling, capitalization, or other typographical error in the address?
    * Do you have sufficient access permissions to the requested item?
drakecai is offline   Reply With Quote
Old 04-23-2009, 07:07 AM   #2
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

did you follow all tutorials from the begining?

have you tested your server?

have you ran a phpinfo file?

what happens when you key localhost into your browser address bar?
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 04-24-2009, 03:41 AM   #3
drakecai
 
Join Date: Apr 2009
Posts: 10
Default

Tested my server through localhost

I got an error about my connection.php in line three
drakecai is offline   Reply With Quote
Old 04-24-2009, 04:13 AM   #4
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

Code:
@database = "localhost";
@username = "root";
@password = "";
is that
$database = "localhost";
$username = "root";
$password = "";
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 04-24-2009, 05:12 AM   #5
drakecai
 
Join Date: Apr 2009
Posts: 10
Default

EDBR I don't get waht your saying... anyways I have changed my settings and I no longer am getting the error but now when I click the submitted button I do not get my two echos. I checked over them and i see no flaw in either one. Here is my updated code.

Code:
<?php
require_once["connections.php"];

////////////////////
$userid = $_POST['userid'];
$password = $_POST['password'];
$submitted = $_POST['submitted'];

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

if [$rowAccount]{

echo "Admin you have logged in.";

}elseif[$submitted]{

echo "LegacyZ is currently under construction. Please check back later.";

}

?>

<title>LegacyZ Login</title>
<form id="form1" name="form1" method="post" action="">
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <table width="200" border="1" align="center">
    <tr>
      <th scope="col">User ID:</th>
      <th scope="col"><label>
        <input type="text" name="userid" id="userid" />
      </label></th>
    </tr>
    <tr>
      <th scope="col">Password:</th>
      <th scope="col"><label>
        <input type="text" name="password" id="password" />
      </label></th>
    </tr>
    <tr>
      <th scope="col">&nbsp;</th>
      <th scope="col"><label>
        <input name="submitted" type="hidden" id="submitted" value="1" />
        <input type="submit" name="button" id="button" value="Submit" />
      </label>
      <label></label></th>
    </tr>
  </table>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</form>
drakecai is offline   Reply With Quote
Old 04-24-2009, 05:44 AM   #6
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

conditional statements are invalid

your using [] but should be using ()
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 04-24-2009, 09:45 PM   #7
drakecai
 
Join Date: Apr 2009
Posts: 10
Default

Alright so If I change all the brackets to () it should be fixed correct?
drakecai is offline   Reply With Quote
Old 04-25-2009, 08:04 AM   #8
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

its a start!

try it
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 04-25-2009, 07:57 PM   #9
drakecai
 
Join Date: Apr 2009
Posts: 10
Default

Nope Doesn't work this is my updated code

Code:
<?php
require_once("connections.php");

////////////////////
$userid = $_POST('userid');
$password = $_POST('password');
$submitted = $_POST('submitted');

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

if ($rowAccount){

echo "Admin you have logged in.";

}elseif($submitted){

echo "LegacyZ is currently under construction. Please check back later.";

}

?>

<title>LegacyZ Login</title>
<form id="form1" name="form1" method="post" action="">
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <table width="200" border="1" align="center">
    <tr>
      <th scope="col">User ID:</th>
      <th scope="col"><label>
        <input type="text" name="userid" id="userid" />
      </label></th>
    </tr>
    <tr>
      <th scope="col">Password:</th>
      <th scope="col"><label>
        <input type="text" name="password" id="password" />
      </label></th>
    </tr>
    <tr>
      <th scope="col">&nbsp;</th>
      <th scope="col"><label>
        <input name="submitted" type="hidden" id="submitted" value="1" />
        <input type="submit" name="button" id="button" value="Submit" />
      </label>
      <label></label></th>
    </tr>
  </table>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</form>
Well same problem still, when I press the submit button the screen flashes once and none of the echos show up.
drakecai is offline   Reply With Quote
Old 04-26-2009, 10:03 AM   #10
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

if you have lifted that from the same page then you need <html <head and <body tags
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj 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 05:34 AM.


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