PDA

View Full Version : login.php setup


socalstyles
01-25-2008, 04:45 AM
ok I am having a simlar problem to rwb who posted earlier in trying to get the login script working.

I am using godaddy for hosting of my website and all those files

but i had to purchase a seperate server to actually use mysql through a remote host so I have some cross server things going on here.

I have all the code put in and have everything running, I can get the server settings inputed correctly and when I go to test the login and password box comes up but when I go to type anything in and click submit it just resets the form and I don't get any feedback (echo) so I know its not working correctly.

I get confused on some of the settings so i have attached some screen shots so maybe you guys can help me get it running.

I get confused between both of my servers and don't know which server I have to include where.

<?php
require_once("Connections/connection.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 ";

}elseif($submitted)(

echo "You dont exist in the system so 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>co
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>login</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
<table width="282" height="93" border="0">
<tr>
<td width="76">User ID </td>
<td width="196"><label for="textfield"></label>
<input type="text" name="userid" id="userid" /></td>
</tr>
<tr>
<td>Password</td>
<td><label for="textfield"></label>
<input type="text" name="password" id="password" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td> <div align="center">
<input name="submitted" type="hidden" id="submitted" value="1" />
</div>
<label for="Submit"></label>
<div align="center">
<input type="submit" name="submitted" value="Submit" id="submitted" />
</div></td>
</tr>
</table>http://i188.photobucket.com/albums/z255/enemiesNl/5.jpg
http://i188.photobucket.com/albums/z255/enemiesNl/3.jpg
http://i188.photobucket.com/albums/z255/enemiesNl/2.jpg
http://i188.photobucket.com/albums/z255/enemiesNl/1.jpg

socalstyles
01-25-2008, 04:52 AM
http://i188.photobucket.com/albums/z255/enemiesNl/6.jpg

socalstyles
01-25-2008, 06:06 AM
I dont know what to do there is to much information provided to me from the hosting companies to know what to fill in. maybe david I can pm you my information and everything and you could help me out. You would be a life saver, of course only if this can't be solved through what ive posted.

lux
01-25-2008, 09:20 AM
To check that your web pages work correctly write a php test page with a simple query such as:


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

//perform query and place results in an array, loop thorugh and display results
$users = mysql_query("select * from users");
while($user = mysql_fetch_assoc($users)){
echo $user['user_name']." ".$user['user_password']."<br />";
}


?>


This should display each of the users name and password on a web page

If you have an error message post it hear.

In the mean time check that the details of you connection.php are correct.

socalstyles
01-25-2008, 09:24 AM
ok this is the error message I got, its bed time where I live so won't probably reply till tomorrow unless u get back at me quick


Warning: main(Connections/connection.php): failed to open stream: No such file or directory in /home/content/b/r/o/brochill/html/Without_FL/test.php on line 2

Fatal error: main(): Failed opening required 'Connections/connection.php' (include_path='.:/usr/local/lib/php') in /home/content/b/r/o/brochill/html/Without_FL/test.php on line 2

socalstyles
01-25-2008, 09:26 AM
Oh on the connections file, what should my database,username, and password all be?

lux
01-25-2008, 09:27 AM
The error message is self explanatory.

Do you even have a connections.php web page uploaded to your server?

Do you even have a connections.php web page with the database details?

socalstyles
01-25-2008, 09:36 AM
this is what is in my connection.php file and yes it is uploaded to my web server. the settings I have put in for the test server is for the ftp on my other server in which all the files are not uploaded. I think that may be a problem, but I need to get everything running on that server that has to do with the databases

<?php

$database = "site1";
$username = "wtf";
$password = "123";

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

?>
Also I dont know what it is pointing to the directory "/home/content/b/r/o/brochill/html/Without_FL/test.php"

That directory doesn't even exist for the most part

lux
01-25-2008, 09:45 AM
Oh on the connections file, what should my database,username, and password all be?

These should be supplied by your hosting company.

Looking at your document tree in the image you uploaded and the error message the web page displays you need to move the test.php file to the same location as the login.php page or change the path specified it your request_once call for the connection.php page.

socalstyles
01-25-2008, 09:46 AM
ok I found out that I switched up my ftp server on dreamweaver when I was messing around so I put it back to my main one and am re uploading all the files just in case. But godaddy doesn't allow 3rd party programs to be used with there mysql databases so thats why I got a new server that would allow me to do this. So i need to set up this server to work with everything which is very confusing to me.

socalstyles
01-25-2008, 09:52 AM
These should be supplied by your hosting company.



would these be for the ftp or for the mysql server.

lux
01-25-2008, 09:58 AM
as your looking to connect to your mysql database i would suggest using the details supplied to connect to your mysql database

let me know if you get it working and please ask if you have any more questions

socalstyles
01-25-2008, 10:01 AM
for this thread we will user server 1(non mysql) with server 2 (mysql)

I need to implement server 2 into server 1 ones web pages because I will keep all the login info on server 2. So I keep all the information the same in dreamweaver but in the php scripting is where I will actually bring in server 2?

Thanks for the help, I really need it and its really appreciated.

I am using EMS mysql lite and have the tables set up on server 2 so how do I do this. I have the files uploaded to server 1 but the sql client setting up all the information on server 2

socalstyles
01-25-2008, 10:09 AM
ok everything is uploaded now I am getting a parse error on line 11

Parse error: parse error, unexpected $ in /home/content/b/r/o/brochill/html/Without_FL/test.php on line 11

Still dont recognize that directory

here is my code on the test script again


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

//perform query and place results in an array, loop thorugh and display results
$users = mysql_query("select * from users");
while($user = mysql_fetch_assoc($users)){

echo $user['user_name']." ".$user['user_password']."<br />";

?>
}

lux
01-25-2008, 10:09 AM
Server 1 : where you have all your web pages

Server 2: mysql database

In the connection.php file which is on Server 1 with all your web pages enter the info to connect to Server 2 where the mysql database is running.

Replace localhost with the ip address supplied that points to server 2, then your username and password.

socalstyles
01-25-2008, 10:14 AM
I don't understand how it knows how to find server2 because none of the ftp information has been put in

socalstyles
01-25-2008, 10:17 AM
Now it wont let me upload my login.php file


Started: 1/25/2008 3:16 AM

Without_FL\login.php - Put operation successful
Connections\connection.php - error occurred - An FTP error occurred - cannot put connection.php. Access Denied. The file may not exist, or there could be a permission problem.

File activity incomplete. 1 file(s) or folder(s) were not completed.
Files updated: 1

Files with errors: 1
Connections\connection.php

Finished: 1/25/2008 3:16 AM

socalstyles
01-25-2008, 10:18 AM
That must be my connection.php file... but I didn't even attempt to upload it. It just uploaded it automatically.

socalstyles
01-25-2008, 10:20 AM
now when i test test.php

ok and replaced the localhost on connection.php with mysql105.mysite4now.com


Warning: main(Connections/connection.php): failed to open stream: No such file or directory in /home/content/b/r/o/brochill/html/Without_FL/test.php on line 2

Fatal error: main(): Failed opening required 'Connections/connection.php' (include_path='.:/usr/local/lib/php') in /home/content/b/r/o/brochill/html/Without_FL/test.php on line 2
it wants to go to that directory but it doesn't exist

lux
01-25-2008, 10:32 AM
1. enter the ip address, username & password supplied by your hosting company to reach your mysql database into the connections.php file

2. In dreamweaver make sure you enter your ftp details into the site definition to ensure you can reach you web pages

3. upload the connections.php file in to the Connections directory

4. make sure you have some users in the user table

5.open a web browser and view the test.php page

socalstyles
01-25-2008, 10:37 AM
i still get this error

Warning: main(../Without_FL/Connections/connection.php): failed to open stream: No such file or directory in /home/content/b/r/o/brochill/html/connections/test.php on line 2

Fatal error: main(): Failed opening required '../Without_FL/Connections/connection.php' (include_path='.:/usr/local/lib/php') in /home/content/b/r/o/brochill/html/connections/test.php on line 2

/home/content/b/r/o/brochill/html/connections/test.php

i dont have that directory

"/home/content/b/r/o/brochill/html/" <-- That doesnt exist but it wants to point to it.

1.I entered a web adress they gave me for the serverip, im sure it works the same (replaced local host with the server ip in connections.php)

2. What do you mean by site definition?

3.the test.php and connection.php files are both in the connections folder... where should login.php be?

4. I have some users in the tables

5. opened the web browser on the test page and got the error posted above.

socalstyles
01-26-2008, 11:31 AM
anyone please help me, this would mean so much to me if someone could help me get this figured out......

davidj
01-26-2008, 07:18 PM
your paths are wrong

thats what the error is telling you

socalstyles
01-27-2008, 03:33 AM
my paths are wrong? Where to I go and change them?

socalstyles
01-27-2008, 06:51 AM
<?php
require_once("Connections/connection.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 ";

}elseif($submitted)(

echo "You dont exist in the system so your not getting in !";

}

?>


does this code look correct?

davidj
01-27-2008, 09:14 AM
this path is incorrect

/home/content/b/r/o/brochill/html/connections/

its telling you that the file test.php does not exist at that location

is the file at that that location???

post the contents of the connections file

socalstyles
01-27-2008, 09:52 AM
I dont know where the hell is gets the path /home/content/b/r/o/brochill from

heres my connections file, ive reworked it a bit and added a query


i need to connect to my database but i dont know how to do this, im not good with php

<?php

$database = "SocalStyles";
$username = "xxx";
$password = "xxxx";
$query = "SELECT $database, $username, $password",

$result = mysql_query($query);



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

?>
//} echo $user['user_name'].' '.$user['user_password'].'<br />'; <-- maybe can fit this in somewhere?

socalstyles
01-27-2008, 09:54 AM
x:\website\socalstyles\connections\connection.php
is where the file is locally

socalstyles.net/connections/connection.php
is where it is remotely

davidj
01-27-2008, 10:09 AM
get in touch with your host

they will guide you correctly