Hello,

I am pretty new to PHP and I am trying to create a admin login page so my
client can view thier product line and orders.  I have MySQL set-up properly
and have data in it and I am able to view information from the db with no
problem. I do all my testing on my local machine before I blast it to the
main web server.  I am using 2000XP Pro, Apache/1.3.23 (Win32) and PHP Ver.
4.2.3.  The main webserver is a Unix system.

The problem I am having is I created a login.php and a include page called
admin.inc.php.  I tried to log-in but the login.php reloads and the login
fields are blank. It should go to the admin.php or give me some type of
error.  I get no errors message.  I was getting errors earlier but I forgot
to put a ; on one line.

I going to copy my login.php and admin.inc.php code hoping that someone
could help my and point out what am I over looking.  I put a #pound sign in
front of the code, I hope this is ok.

LOGIN CODE

#<?php include("../classes/admin.inc.php"); ?>
#<?php
#
# // Main Code - Verifies the form data, and inserts into
# // the users table in the Database
#  if($HTTP_POST_VARS['Submit']=='Create User'){
#  $error = verify_data($HTTP_POST_VARS);
#  if ($error == "")
#   $success = "User inserted successfully";
# }
#?>

#<?php
#function verify_data($formdata) {
# // This function uses the functions in the include file,
# // and uses them to validate various aspects of the form.
# // If validation fails, it returns $error, the appropriate error message
# // If validation suceeds, return true
# $error = "";
# $form_data = trim_data($formdata);
# $user = $form_data['username'];
#
# // check all form fields are filled in
# if (!check_form($form_data)) {
#  $error="All Form Fields must be filled in";
#  return($error); }
#
# // check password and confirmation password match
# if (!confirm_password($form_data, 'password', 'confirmpassword')) {
#  $error = "Password and Confirm Password do not match";
#  return($error); }
#
# // check length of password
# if (!check_password_length($form_data, 'password', 6)) {
#  $error = "Password should be 6 characters or more";
#  return($error); }
#
# // check that username is unique
# $check = check_unique($user, 'sunwestsilver', 'localhost' , 'blade',
'123456', 'access_level', 'username');
# if ($check != "true") {
#  $error = "Username is already in user, select another";
#  return($error); }
#
# // if validated successfully, insert data into table
# $insert_check = insert_data($formdata);
#
# // if error with insertion, return error
# if ($insert_check != "true")
#  return($insert_check);
#
# // form validated and record inserted successfully
# return("");
#}
#
#function insert_data($formdata) {
# // Insert Data into users table
# // $formdata = form array
#
# // setup database connection variables, insert as correct for your server
# $error = "";
# $myhost = "localhost";
# $myuser = "blade";
# $mypass = "123456";
# $mydb = "sunwestsilver";
#
# // setup data to insert
# $firstName = $formdata['firstName'];
# $lastName = $formdata['lastName'];
# $username = $formdata['username'];
# $password = $formdata['password'];
# $status = $formdata['status'];
#
# // encrypt the password using the key "123456"
# $password = crypt($password,"123456");
#
# // connect to mySQL server
# $mysql = mysql_connect($myhost, $myuser, $mypass);
# if (!$mysql) {
#  $error = "Cannot connect to mySQL server";
#  return($error);
#  }
# // Connect to Database
# $mysqldb = mysql_select_db($mydb, $mysql);
# if (!$mysqldb) {
#  $error = "Cannot open Database";
#  return($error);
#  }
# // Insert Data
# $myquery = "INSERT INTO access_level ( firstName, lastName, username,
password, status) VALUES ('$firstName', '$lastName', '$username',
'$password', #'$status')";
# $result = mysql_query($myquery, $mysql);
# if (!$result) {
 #$error = "Cannot run Query";
 #return $error;
 #}
#// Return True if record written successfully
#return("true");
#}
#?>

INCLUDE ADMIN.INC CODE (admin.inc.php)

#<?php
##########################################
##     admin.inc.php include file       ##
##########################################

#function trim_data($formdata)
#{
#  // Trim any leading or trailing spaces
#  // $formdata = Form Data Array
#  foreach($formdata as $key => $value)
#{
#  $key = trim($key);
#  $value = trim($value);
#}
#  return $formdata;
#}
#
#function check_form($formdata)
#{
#  // Check all fields are filled in
#  // $formdata = Form Data Array
#  foreach ($formdata as $key => $value)
#  {
# if (!isset($key) || $value == "" )
# return false;
# }
#  return true;
#}
#
#function check_password_length($formdata, $password, $minlen)
#{
#  // Check that password is required length
#  // $formdata = Form Data Array
#  // $password = Name of password field
#  // $minlen = Minimum number of password characters
#  if (strlen($formdata[$password]) < $minlen)
#    return false;
#  else
# return true;
#}
#
#function confirm_password($formdata, $password1, $password2)
#{
#  // Check that two passwords given match
#  // $formdata = Form Data Array
#  // $password1 = Name of first password field
#  // $password2 = Name of second password field
#
#  if ($formdata[$password1] === $formdata[$password2])
# return true;
#  else
# return false;
#}
#
#function check_unique($formvalue, $db, $dbhost, $dbuser, $dbpassword,
$table, $field) {
# // Checks a table in a database, so see if passed value already exists
# // $formvalue = Value you are checking to see if it is unique or not
# // $db = mySQL Database Name
# // $dbhost = mySQL Server address eg localhost
# // $dbuser = mySQL user name
# // $dbpassword = mySQL password
# // $table = mySQL Table to search
# // $field = mySQL Field to search
#
# $error = "";
# // Connect to the mySQL Server
# $mysql = mysql_connect($dbhost, $dbuser, $dbdbpassword);
# if(!$mysql)
# {
#  $error = "Cannot connect to Database Host";
#  return($error);
# }
# // Open the mySQL Database
# $mysqldb = mysql_select_db($db);
#  if(!$mysqldb)
# {
#  $error = "Cannot open Database";
#  return($error);
# }
# // Query Table to see if $formvalue is unique
# $myquery = "SELECT * FROM $access_level WHERE $username = '$formvalue'";
# $result = mysql_query($myquery);
# if (!$result)
#  {
#  $error = "Cannot run Query";
#  return($error);
# }
# // Get number of Records found, should be 0 if $formvalue is unique
# $unique = mysql_num_rows($result);
#
# if ($unique > 0)
# {
#  $error = $formvalue. " already in use";
#  return($error);
# }
# // Return true if $formvalue is unique
# return("true");
#}
#?>




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to