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
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
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, support@freehostia.com 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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.