Jump to content

Login System Error


avatar.alex

Recommended Posts

Ok I pretty much have this system done I just need some help with this part.

 

It all works except for when I login.

The registration work fine!!!

The problem is on line 20

 

Parse error: parse error, unexpected T_STRING in /home/www/avatar-alex.freehostia.com/login.php on line 20

 

<?php

//Database Information

$dbhost = "mysql2.freehostia.com";
$dbname = "alealb52_login";
$dbuser = "alealb52_login";
$dbpass = "****";

//Connect to database

mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());


session_start();
$username = $_POST[‘username’];
$password = md5($_POST[‘password’]);

$query = “Select * from users where username=’$username’ and password=’$password’ ”;

$result = mysql_query($query);

if (mysql_num_rows($result) != 1) {
$error = “Bad Login”;
    include “login.html”;

} else {
    $_SESSION[‘username’] = “$username”;
    include “memberspage.php”;
}

?>

Link to comment
https://forums.phpfreaks.com/topic/79155-login-system-error/
Share on other sites

<?php
session_start();
//Database Information

$dbhost = "mysql2.freehostia.com";
$dbname = "alealb52_login";
$dbuser = "alealb52_login";
$dbpass = "siko65";
//Connect to database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

$username = $_POST['username'];
$password = md5($_POST['password']);
$query = "Select * from users where username='$username' and password='$password' ";
$result = mysql_query($query);
if (mysql_num_rows($result) != 1) {
$error = "Bad Login";
    include "login.html";

} else {
    $_SESSION["username"] = $username;
    include "memberspage.php";
}
?>

try..

Link to comment
https://forums.phpfreaks.com/topic/79155-login-system-error/#findComment-400626
Share on other sites

The Login.php file works fine thanks so much!!!!

 

Ok thanks now a new problem...i though everything works it turns out the members page has an error I DON'T KNOW HOW!!! But it does:

 

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.



--------------------------------------------------------------------------------

Apache/1.3.33 Server at avatar-alex.freehostia.com Port 80

 

<?
// members page
session_start();

//Database Information

$dbhost = "mysql2.freehostia.com";
$dbname = "alealb52_login";
$dbuser = "alealb52_login";
$dbpass = "****";

//Connect to database

mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

$query="SELECT * FROM users ";
$result=mysql_query($query);
$num = mysql_num_rows ($result);

if ($num > 0 )
{
$i=0;
while ($i < $num)
{
$username = mysql_result($result,$i,"category");

if (!$username)
{
print "Please login below!";
include 'login.html';
}
else if ($username == "admin")
{
echo "I can edit members here, right!<br >";
}

else
{
print"<html>";
print"<head>";
print"<title>MEMBERS ONLY</title>";
print"</head>";
print"<body>";
print"Your Members Page....";
print"</body>";
print"</html>";
}

}
}
?>

 

P.S. Sorry about all the troble I am still learning how to use PHP an MySQL sorry :(

Link to comment
https://forums.phpfreaks.com/topic/79155-login-system-error/#findComment-400654
Share on other sites

you have a sql error

 

$query="SELECT * FROM login ";
$result=mysql_query($query) or die (mysql_error());
$num = mysql_num_rows ($result);

try to add a sql error to know what causes this prob..

I found wat i did. I didn't make a login table i changed it to users.

 

I changed the error

Link to comment
https://forums.phpfreaks.com/topic/79155-login-system-error/#findComment-400665
Share on other sites

I wasn't posting to you.  What good does giving him new code without explaining to him what you did?  He won't learn if you don't show him how to fix it.

 

session_start();

 

Should be the first line of code after <?php

i did and thats not the errors trying to say!

Link to comment
https://forums.phpfreaks.com/topic/79155-login-system-error/#findComment-400760
Share on other sites

I wasn't posting to you.  What good does giving him new code without explaining to him what you did?  He won't learn if you don't show him how to fix it.

 

session_start();

 

Should be the first line of code after <?php

i did and thats not the errors trying to say!

 

Having it explained to me helps me I can also learn by going through the code!!! Thanks! :)

Link to comment
https://forums.phpfreaks.com/topic/79155-login-system-error/#findComment-400764
Share on other sites

@revraz

i hate teaching everything like teaching a kidz STOP LOOK AND LISTEN.. if you want ot become a programmer and you cant figure out this simple thing i mean figuring out what and why your system is fixed then you must turn your career as a designer not a programmer..

 

i hate explaining everything y?

when ever i gave an edited code in expecting that he os she will give it a try to figure it out all by him/her self  sometimes it feels great when you your self know something about something..learning like being spoon feed well turn you as a week developer FOR me programming is one of the hardest task if you look at it carefully..

I love hearing this words "AHh thats it i made it " and not "yes thank you " he might know something but where is the effort i help for free so if you want spoon feeding you have to pay me lol...

BOW !

Link to comment
https://forums.phpfreaks.com/topic/79155-login-system-error/#findComment-400768
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.