Jump to content

Archived

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

likwidmonster

How do you make user acounts and user login on a website

Recommended Posts

to likwidmonster

lol

i like to not make sense when i make websites, and that picture isn't me.

i have yet to update the main page to the real perpous of the site, you can check it out soon to see the real perpous

 

 

Share this post


Link to post
Share on other sites

HAHA... this has literally made me laugh!!!

 

 

anyway... the problem with the code, if no-one else hasn't already noticed, it says:

 

<?PHP
echo "PHP is working;
?>

 

That is wrong, it is meant to be:

 

<?PHP
echo "PHP is working";
?>

 

You MUST close ALL quotes (" OR ') otherwise you will get stupid (really stupid) errors. But go ahead and try the correct code in this post and, since it has given you an error, PHP IS WORKING!

Share this post


Link to post
Share on other sites

wow sorry, im incredibly stupid but i guess it proved that you have php

lol

Thanks for pointing that out!!

Share this post


Link to post
Share on other sites

then again... you are only 14... and im 18... well nearly... but ive been doing php for almost a year... and jsut started to learn javascript... so yea... just tell me if thats all you needed to know likwidmonster. Due to the fact that it did give you an error, kinda makes it obvious that php is enabled. so just install any php script. and you domain will probably have MySQL aswell... so have a look into that and see what you can really achieve

Share this post


Link to post
Share on other sites

It has an error it says "/home/content/d/a/r/darrencoon/html/nathan/test.php" as I said I, am using my teacher's sub domain. He said this happened because I do not have it going to a database.

Share this post


Link to post
Share on other sites

Then your teacher doesn't know what he is talking about - the 'php is enabled' script doesn't require a database.

 

Give us the rest of the error. That was only a path name, not an error.

Share this post


Link to post
Share on other sites

...as I said I, am using my teacher's sub domain.

 

as I said, using a sub-domain doesn't mean anything. You probably just picked up the snippet of code that had the syntax error as identified on the previous page.

Share this post


Link to post
Share on other sites

Then you don't know how to read then mjdamato I got the code from lewis987!

 

No I can read perfectly fine. Nowhere did you state what code you used that produced the error you posted on Reply#31 (in Reply#26 you stated that haku's code produced an error). So where, exactly, did you state that you used the code provided from lewis987?

 

Why are you being so argumentative? For some reason you are hung up on the obsession that because your site is being run on a sub-domain that it would somehow function differently. That is just not the case. I'm not trying to be rude (unlike trying to question someone's reading ability), but you seem to ignore everything that everyone has stated. When asked a question by those trying to help you, you only respond with partial responses or change the subject entirely. If we ask you to try somethign and it doesn't work, just post back EXACTLY what did or did not work along with any error messages. We do not have access to your system so we rely upon you to give complete and accurate details.

 

As haku stated, the error you recieved supports the fact that PHP is enabled for you. However, you didn't respond to his request to provide the full error which would explain the problem (which is in all likelyhood just a syntax error). Also, as he stated, your 'instructor' doesn't know what he is talking about - PHP does not require a database. You can create a PHP page that interacts with a database, but that is another matter. First let's get the PHP issue straitened out.

Share this post


Link to post
Share on other sites

You are more patient than I damato - this kid is starting to annoy me.

 

Kid: damato said it, but I'll say it again - get it out of your head that it matters that you are on a subdomain. It doesn't. It will function exactly the same as a domain.

Share this post


Link to post
Share on other sites

Okay! I, am not trying to be argumentative! It may seem like that. The whole reason of this thread was to try to make a login in JavaScript then I wanted to know what I could do with a linux sub-domain. I wish I had a domain but I dont, so i ,am trying to learn all I can from this so eventually I can have one and know what I, am doing! I do not have any software I think you mentioned that below.

:)

Share this post


Link to post
Share on other sites

Well, you CAN'T do a login with JavaScript (at least not one that is of any value - anyone could log in by looking at the page source). You CAN do it with PHP (with or without a database - just use a flat file).

 

There is no such thing as a "Linux sub-domain". The fact that the server is Linux vs. Windows or a sub-domain or a domain has nothing to do with any of this - nothing.

 

Again, from the partial error message you posted (Which you still haven'tprovided full details for) it appears you can use PHP. If that's the case you can have a login function. If no database is availabel then you can use flat files.

Share this post


Link to post
Share on other sites

okay thankyou! Ummm.... Can you tell me how to do a flat file? :) and sorry you have to put up with me

P.S.aku you just not talk if i, am annoying you! (Non-sarcastic) :)

Share this post


Link to post
Share on other sites

Ok, here is a vert, very simple script that would work - although it would need a lot more work. Also, there are ready made classes that will allow you to use flat files just like a database.

 

Create a text file called user_list.txt and enter the username and passwords like so:

michael|testing
robert|whatever

 

Then create a PHP file such as this:

<?php

function validUser() {

  $uname = $_POST['uname'];
  $pword = $_POST['pword'];

  $accountFile = "user_list.txt";
  $accounts = file($accountFile);

  foreach ($accounts as $userData) {
    list($username, $password) = explode('|', $userData);
    if (trim(strtolower($username))==trim(strtolower($uname))) {
        return (trim($password)==trim($pword));
    }
  }
  return false;
}

$error = '';

if (isset($_POST['uname']) || isset($_POST['uname'])) {
    if (validUser()) {
        echo "<html><head></head><body>Log user in.</body></html>";
        exit;
    } else {
        $error = "Username/password entered invalid";
    }
}

?>

<html>
<head></head>
<body>
<?php echo $error; ?>
<form method="post">
Username: <input type="text" name="uname" value="<?php echo $_POST['uname']; ?>"><br>
Username: <input type="password" name="pword"><br>
<button type="submit">Submit</button>
</form>
</body>
</html>

 

Again this is only a basic example and I would not suggest using this code as is - but I'm not going to take the time to code all of this out. This only shows that it will work.

Share this post


Link to post
Share on other sites

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