Jump to content

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


likwidmonster

Recommended Posts

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!

Link to comment
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

Link to comment
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.

Link to comment
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.

Link to comment
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.

:)

Link to comment
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.

Link to comment
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.

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.