View Full Version : PHP login problem

12-29-2007, 09:33 PM
I am having a similar problem. David, I have been going through your tutorials and they are extremely helpful--by far the best thing I have found on the web. I am trying to insert a password login right now, and I can get my pages to work on my local (Apache) host, but I can't get my file to correctly pull from the databases on my web server (StartLogic.) I finished your first password tutorial and I just keep getting the message "You don't esixt in the system so you can't enter." I think the problem is in my connections.php file, but I'm not sure. What should the host name be for a remote server? Any help is greatly appreciated.

12-30-2007, 09:44 AM
you would get an error if you couldnt connect to your db

please post your code

12-30-2007, 02:22 PM
The code for my connections.php file is:

$database = "lisaleit";
$username = "lisaleit";
$password = "lisaleit1";
$link = mysql_connect('apprenticeshipparenting.startlogicm ysql.com', $username, $password);
$db = mysql_select_db($database, $link);

and for my login.php it is:

require_once("Connections/connections.php"); // database connection
//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 "The record exists so you can enter";
echo "You don't exist in the system so you are not able to enter!";
<!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">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<form name="form1" id="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
<table width="270" border="2" cellspacing="0" cellpadding="0">
<td width="92" height="49">User ID</td>
<td width="170"><input name="userid" type="text" id="userid" /></td>
<td height="54">Password</td>
<td><input name="password" type="password" id="password" /></td>
<td height="49">&nbsp;</td>
<td><input name="submitted" type="hidden" id="submitted" value="1" />
<input type="submit" name="Submit" value="Submit" /></td>

12-30-2007, 06:11 PM
humor me

replace this in your form tag

action="<?php $_SERVER['PHP_SELF'];?>"with

action="pagename.php"with pagename.php being the page you code is in

12-30-2007, 06:22 PM
I got it work, but thanks for being willing to work on it. (I was missing a $ and there was an issue with my web server.) Now I'm on to the next tutorials!!

12-30-2007, 07:02 PM
ah yes

i can see it now

in the SQL

cant see the wood for the trees