This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-11-10 07:20:35

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Web-languages: Help and helper thread

The Scratch advanced forum is currently receiving a lot of threads either sharing information on how to use various web programming languages or asking for help in using them and this is taking up quite a bit of space. This thread aims to unify those questions so that there is one place where potential helpers can check for questions they might answer and where individual questions have a higher chance of being addressed.

HTML Tutorials
     Easy
          How to make a web-page play music/sounds. ~WindowsExplorer

PHP Tutorials
     Easy
          PHP Variables ~Sparks

Javascript Tutorials
     Moderate
          JavaScript Objects Part I: Properties ~Hardmath123
          JavaScript Objects Part II: Methods ~Hardmath123
          JavaScript Objects Part III: Custom Objects ~Hardmath123

How to write a good tutorial. Consider reading this to get the most out of your submission.

Statistics!

Last edited by sparks (2011-11-11 12:18:22)


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#2 2011-11-10 07:25:18

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Web-languages: Help and helper thread

^home
HTML Tutorial: How to make a web-page play music/sounds

Shared by: WindowsExplorer
Difficulty: Easy

Code:

<iframe src='MUSIC_FILE_LINK' width='0' height='0'></iframe>

Where to use: Anywhere between the <body> and </body> tags in your document.

Notes:
o Replace the text MUSIC_FILE_LINK with the link URL to your sound.

o This uses an iframe and will therefore leave a small white dot on your screen. To completely hide the iframe containing your sound, optionally add a CSS display attribute to the code and use this instead:

Code:

<iframe src='MUSIC_FILE_LINK' width='0' height='0' style = 'display:none;'></iframe>

^home

Last edited by sparks (2011-11-10 13:05:37)


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#3 2011-11-10 07:31:39

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Web-languages: Help and helper thread

Interesting! I'll be contributing a lot a JS, I hope. Look out!


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#4 2011-11-10 07:33:59

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Web-languages: Help and helper thread

Hardmath123 wrote:

Interesting! I'll be contributing a lot a JS, I hope. Look out!

(y) Sounds good! With any luck this will allow people to continue discussing web-languages here without creating a thread for every question - which I know mildly annoys some people  smile


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#5 2011-11-10 09:39:47

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Web-languages: Help and helper thread

Thanks for creating this Sparks! This will probably become very useful for later in the future.  smile

Offline

 

#6 2011-11-10 10:17:20

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Web-languages: Help and helper thread

Yays!


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#7 2011-11-10 10:18:34

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Web-languages: Help and helper thread

Can someone post a tutorial on how to make a download in HTML/CSS/JS, and also playing sounds with it?  My chances of getting a server aren't so great, so I'm stuck with HTML/CSS/JS.

Offline

 

#8 2011-11-10 10:35:56

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: Web-languages: Help and helper thread

Awsome! Thank's for featuring my code in it  smile


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#9 2011-11-10 10:52:51

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Web-languages: Help and helper thread

maxskywalker wrote:

Can someone post a tutorial on how to make a download in HTML/CSS/JS, and also playing sounds with it?  My chances of getting a server aren't so great, so I'm stuck with HTML/CSS/JS.

There is not way to download with JS unless it is from your server or the file you are trying to download has 'Access-Control-Allow-Origin: *' in its header (most sites don't have this.)


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#10 2011-11-10 10:53:48

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: Web-languages: Help and helper thread

Is there a way to UN-MD5 something in php? I have a login and register and when I md5 the password, there is no way to undo it, so how would md5ng passwords work?


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#11 2011-11-10 11:02:17

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Web-languages: Help and helper thread

WindowsExplorer wrote:

Is there a way to UN-MD5 something in php? I have a login and register and when I md5 the password, there is no way to undo it, so how would md5ng passwords work?

Just compare the MD5 of the entered password with the real MD5 password in the db.

md5 are not ment to be UN-MD5'd by the way. That's the whole purpose of MD5

Last edited by MathWizz (2011-11-10 11:03:33)


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#12 2011-11-10 11:13:30

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: Web-languages: Help and helper thread

MathWizz wrote:

WindowsExplorer wrote:

Is there a way to UN-MD5 something in php? I have a login and register and when I md5 the password, there is no way to undo it, so how would md5ng passwords work?

Just compare the MD5 of the entered password with the real MD5 password in the db.

md5 are not ment to be UN-MD5'd by the way. That's the whole purpose of MD5

Yes, but it doesn't seem to work. It seems like it has two different md5 values  sad


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#13 2011-11-10 11:21:16

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Web-languages: Help and helper thread

WindowsExplorer wrote:

MathWizz wrote:

WindowsExplorer wrote:

Is there a way to UN-MD5 something in php? I have a login and register and when I md5 the password, there is no way to undo it, so how would md5ng passwords work?

Just compare the MD5 of the entered password with the real MD5 password in the db.

md5 are not ment to be UN-MD5'd by the way. That's the whole purpose of MD5

Yes, but it doesn't seem to work. It seems like it has two different md5 values  sad

Then the passwords must be different.


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#14 2011-11-10 11:33:01

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: Web-languages: Help and helper thread

MathWizz wrote:

WindowsExplorer wrote:

MathWizz wrote:


Just compare the MD5 of the entered password with the real MD5 password in the db.

md5 are not ment to be UN-MD5'd by the way. That's the whole purpose of MD5

Yes, but it doesn't seem to work. It seems like it has two different md5 values  sad

Then the passwords must be different.

nope - both the same passes.


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#15 2011-11-10 11:41:39

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Web-languages: Help and helper thread

sparks, the sound thingie for PHP won't work without tags. I suggest you use single quotes instead to encase the html,so that there is no need to use escape characters for the "".

Offline

 

#16 2011-11-10 13:01:05

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Web-languages: Help and helper thread

LS97 wrote:

sparks, the sound thingie for PHP won't work without tags. I suggest you use single quotes instead to encase the html,so that there is no need to use escape characters for the "".

Thank you, I'll fix it up.

@WindowsExplorer:

1) user enters password

2) password MD5'd

3) password sent to database in MD5 format for protection

4) User logs in by entering their unencrypted password

5) MD5'd password retrieved from database

6) password entered by login form MD5'd, then compared to the one you pulled from the database

something like:

Code:

if(md5($_POST['password']) == $encryptedPass) {
     $passwordState = True;
}

You should not be un-MD5-ing passwords of your users as they should be the only ones who know their pass, you are breaching their privacy if you take their passwords and view them without telling them that you can/will do so.
_____________________________________________

EDIT: As it is technically nothing more than pure HTML edited, I have recategorised WindowsExplorer's tutorial to the HTML section  smile

Last edited by sparks (2011-11-10 13:06:51)


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#17 2011-11-10 13:08:02

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: Web-languages: Help and helper thread

sparks wrote:

LS97 wrote:

sparks, the sound thingie for PHP won't work without tags. I suggest you use single quotes instead to encase the html,so that there is no need to use escape characters for the "".

Thank you, I'll fix it up.

@WindowsExplorer:

1) user enters password

2) password MD5'd

3) password sent to database in MD5 format for protection

4) User logs in by entering their unencrypted password

5) MD5'd password retrieved from database

6) password entered by login form MD5'd, then compared to the one you pulled from the database

something like:

Code:

if(md5($_POST['password']) == $encryptedPass) {
     $passwordState = True;
}

You should not be un-MD5-ing passwords of your users as they should be the only ones who know their pass, you are breaching their privacy if you take their passwords and view them without telling them that you can/will do so.

That's what I'm trying to do, but I have it this way:

Code:

$username = $_POST['username']; // Gets the inputted username from the form 
$password2 = $_POST['password']; // Gets the inputted password from the form
$password = md5($password2);
$icon = $resultng;

$time = time(); // Gets the current server time 
$check = $_POST['setcookie']; // Checks if the remember me button was ticked 

$db = mysql_connect($dbHost,$dbUser,$dbPass); // Connection Code 
mysql_select_db($dbname,$db); // Connects to database 

$query = "SELECT user, pass FROM login WHERE user = '$username' AND pass = '$password'"; 
$result = mysql_query($query, $db);
$queryr = "SELECT * FROM login WHERE user = '$username'"; 
$resultr = mysql_query($queryr, $db); 
$row2=mysql_fetch_array($resultr);
$type = $row2['type'];
$icon = $row2['icon'];
if(mysql_num_rows($result)) {
logged in code
} else {
echo "wrong pass";
}

i keep getting wrong pass error.


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#18 2011-11-10 13:23:52

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Web-languages: Help and helper thread

sparks wrote:

LS97 wrote:

sparks, the sound thingie for PHP won't work without tags. I suggest you use single quotes instead to encase the html,so that there is no need to use escape characters for the "".

Thank you, I'll fix it up.

@WindowsExplorer:

1) user enters password

2) password MD5'd

3) password sent to database in MD5 format for protection

4) User logs in by entering their unencrypted password

5) MD5'd password retrieved from database

6) password entered by login form MD5'd, then compared to the one you pulled from the database

something like:

Code:

if(md5($_POST['password']) == $encryptedPass) {
     $passwordState = True;
}

You should not be un-MD5-ing passwords of your users as they should be the only ones who know their pass, you are breaching their privacy if you take their passwords and view them without telling them that you can/will do so.
_____________________________________________

EDIT: As it is technically nothing more than pure HTML edited, I have recategorised WindowsExplorer's tutorial to the HTML section  smile

Yeah, the point of hashing things is so people can't figure out the passwords. So what you can do is:

Code:

// Register:
$user = $_POST['username'];
$pass = md5($_POST['password']);
$result = mysql_query("INSERT INTO users_table (username, password) VALUES '$user', '$pass'");

//Login
$user = $_POST['username'];
$pass = md5($_POST['password']);
$result = mysql_query("SELECT * FROM users_table WHERE username='$user'");
$row = mysql_fetch_array($result);
if ($pass == $row['password']) { echo 'Login successful'; }

By the way, that code I made, is so insecure, that I am speechless; but that is just to show the concept. Basically it md5s the password then it checks to see if it is the same md5'd password.

So here is what happens:

The user inserts the data into a form:
Username: RandomUser1234
Password: RandomPassword1234

The data is sent to the server: Note the password is not sent encrypted yet, the server gets the data then encrypts ( hashes ) it.
$user = 'RandomUser1234'
$pass = '00567bc61bab9cdd677c676559d2e5f5' // Password "RandomPassword1234" is encrypted into '00567bc61bab9cdd677c676559d2e5f5'

Now if this were the registration page it would insert that data into the database:
mysql_query("INSERT INTO users_table (username, password) VALUES '$user', '$pass'");

If it's the login ( and the user has already registered ) it checks to see if the hashes are the same:

if ('00567bc61bab9cdd677c676559d2e5f5'='00567bc61bab9cdd677c676559d2e5f5') { echo 'Logged in!'; }

But if they type something else in like "RandomNotPassword" ( which is encrypted into 'e6b3dadbb2f33811d31ac4eeea99341d' ):

if ('e6b3dadbb2f33811d31ac4eeea99341d'=='00567bc61bab9cdd677c676559d2e5f5' { echo 'It will never get here, because the passwords are not the same.'; }

So either you aren't inserting the hashed password correctly, or you are not hashing the password and checking it to the one in the database correctly.

EDIT: I spent an entire 30 minutes preparing this post and then someone replies before I can post it... Can you show us the registration code as well?

Last edited by Magnie (2011-11-10 13:25:19)

Offline

 

#19 2011-11-10 13:34:37

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Web-languages: Help and helper thread

So sorry, Magnie, your explaination is much, much better than mine though! Perhaps you could turn it into a tutorial in creating login systems?  smile


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#20 2011-11-10 13:36:36

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: Web-languages: Help and helper thread

Still not working  sad
I have

Code:

$username = $_POST['username'];
$pass3r = md5($_POST['password']);
$result3r = mysql_query("SELECT * FROM login WHERE user='$username'");
$row3r = mysql_fetch_array($result3r);
if ($pass3r == $row3r['pass']) {

http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#21 2011-11-10 14:17:40

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Web-languages: Help and helper thread

@sparks: It's a possibility.  smile

@WindowsExplorer: Can you give me the registration code you have?

Offline

 

#22 2011-11-10 14:39:13

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Web-languages: Help and helper thread

MathWizz wrote:

maxskywalker wrote:

Can someone post a tutorial on how to make a download in HTML/CSS/JS, and also playing sounds with it?  My chances of getting a server aren't so great, so I'm stuck with HTML/CSS/JS.

There is not way to download with JS unless it is from your server or the file you are trying to download has 'Access-Control-Allow-Origin: *' in its header (most sites don't have this.)

Um, it would be me making the site.

Offline

 

#23 2011-11-10 16:01:05

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: Web-languages: Help and helper thread

Magnie wrote:

@sparks: It's a possibility.  smile

@WindowsExplorer: Can you give me the registration code you have?

Code:

<link rel="stylesheet" type="text/css" href="global.css" />
<script type="text/javascript">
function disabled2() {
alert("This website is in beta test mode. Therefore your account will not be activated, and will not work when logging in.");
}
</script>
<?php
include "connect.php";
if ($_GET['error'] == "true") {
include "demo.html";
echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
Registrations are disabled as the site is in beta mode.</g></p>";
} else {
include "demo.html";
$badlist = array("censored words are here");

$submit = $_POST['submit'];
$username = strip_tags($_POST['username']);
$password = $_POST['password'];
$ipaddress = $_SERVER['REMOTE_ADDR'];
$email = $_POST['email'];
$repeatpassword = strip_tags($_POST['repeatpassword']);
$date = date("Y-m-d");
$namecheck = substr($username, -2);
$namecheck2 = substr($username, -1);
$namecheck2 = substr($username, -1);
$namecheck3 = str_word_count($username);
$usernamefr = strtolower ($username);
$resultrug = mysql_query("SELECT * FROM `login` WHERE `user`='$username'") or die ("Error:" . mysql_error());
$num_rowsgyr = mysql_num_rows($resultrug);
if ($submit) {
    if ($num_rowsgyr > "0") {
    echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
    Registration failed. The username \"$username\" is already taken. Sorry about that.</g></p>";
    mysql_query("INSERT INTO failed_registrations (ip, time, reason, user, pass, email)
    VALUES ('$ip', '$date', 'Attempting to use an already taken username.', '$username', '$password', '$email')");
    }
    if ($namecheck3 > "3") {
    echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
    Registration failed. No more than three words are allowed in your username.</g></p>";
    mysql_query("INSERT INTO failed_registrations (ip, time, reason, user, pass, email)
    VALUES ('$ip', '$date', 'Attempting to use over three words in username.', '$username', '$password', '$email')");
    }
    if ($usernamefr == $badlist) {
    echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
    Registration failed. Your name contains bad words.</g></p>";
    mysql_query("INSERT INTO failed_registrations (ip, time, reason, user, pass, email)
    VALUES ('$ip', '$date', 'Attempting to use bad words in username.', '$username', '$password', '$email')");
    }
    if ($namecheck == "'s" || $namecheck == "'S" || $namecheck2 == "*") {
    echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
    Registration failed. Please don't try to trick our system again.</g></p>";
    mysql_query("INSERT INTO failed_registrations (ip, time, reason, user, pass, email)
    VALUES ('$ip', '$date', 'Attempting to trick the registration system.', '$username', '$password', '$email')");
    } else {
    if ($username && $password && $repeatpassword && $email) {
        if ($password == $repeatpassword && !($num_rowsgyr > "0")) {
        $passwordmd5 = md5($password);
        mysql_query("INSERT INTO login (user, pass, ban, email, ip, type, time)
        VALUES ('$username', '$passwordmd5', 'false', '$email', '$ip', 'User', '$date')");
        $to1 = "support@plaxon.org";
        $subject1 = "New registration at Mini Universe: $username";
        $message1 = "A new user has registered at Mini Universe!
        
        Username: $username
        Password: $password";
        $from1 = "notification-index@plaxon.org";
        $headers1 = "From:" . $from1;
        mail($to1,$subject1,$message1,$headers1);
        $to = "$email";
        $subject = "Welcome to Mini Universe, $username!";
        $message = "Welcome to Mini Universe, $username! Your account has successfully been created! You can login with the following details:
        
        Username: $username
        Password: $password
        
        Have fun,
        Mini Universe team!";
        $from = "support@plaxon.org";
        $headers = "From:" . $from;
        mail($to,$subject,$message,$headers);
        echo "<p><g style=\"border-style:solid; border-color:darkgreen; background-color:green; color:darkgreen;\">
        You are registered! You can now login! Your account details have been sent to <b>$email</b>! (Also, don't forget to check your spam folder!) <a href=\"login.php\">[Login Now]</a></g></p>";
        
        } if (!($password == $repeatpassword)) {
            echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
            The passwords you entered do not match. Please try again.</g></p>";
        }
        } if (!($username && $password && $repeatpassword)) {
        echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
        All fields are required to create your account. Please try again.</g></p>";
    }
}
}
echo '<p>
<html>
<form action="register.php" method="POST">
<p><label for="username">Username: <input type="text" name="username" id="username" maxlength="25" /></label></p> 
<p><label for="password">Password: <input type="password" name="password" id="password" maxlength="25" /></label></p> 
<p><label for="repeatpassword">Password: <input type="password" name="repeatpassword" id="repeatpassword" maxlength="25" /></label></p> 
<p><label for="email">Email: <input type="text" name="email" id="email" maxlength="100" /></label></p> 
<p><input type="submit" name="submit" value="Join Now!"></p>
</form>
</p>
</html>';
}
?>

http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#24 2011-11-10 16:04:57

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Web-languages: Help and helper thread

WindowsExplorer wrote:

Magnie wrote:

@sparks: It's a possibility.  smile

@WindowsExplorer: Can you give me the registration code you have?

Code:

<link rel="stylesheet" type="text/css" href="global.css" />
<script type="text/javascript">
function disabled2() {
alert("This website is in beta test mode. Therefore your account will not be activated, and will not work when logging in.");
}
</script>
<?php
include "connect.php";
if ($_GET['error'] == "true") {
include "demo.html";
echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
Registrations are disabled as the site is in beta mode.</g></p>";
} else {
include "demo.html";
$badlist = array("censored words are here");

$submit = $_POST['submit'];
$username = strip_tags($_POST['username']);
$password = $_POST['password'];
$ipaddress = $_SERVER['REMOTE_ADDR'];
$email = $_POST['email'];
$repeatpassword = strip_tags($_POST['repeatpassword']);
$date = date("Y-m-d");
$namecheck = substr($username, -2);
$namecheck2 = substr($username, -1);
$namecheck2 = substr($username, -1);
$namecheck3 = str_word_count($username);
$usernamefr = strtolower ($username);
$resultrug = mysql_query("SELECT * FROM `login` WHERE `user`='$username'") or die ("Error:" . mysql_error());
$num_rowsgyr = mysql_num_rows($resultrug);
if ($submit) {
    if ($num_rowsgyr > "0") {
    echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
    Registration failed. The username \"$username\" is already taken. Sorry about that.</g></p>";
    mysql_query("INSERT INTO failed_registrations (ip, time, reason, user, pass, email)
    VALUES ('$ip', '$date', 'Attempting to use an already taken username.', '$username', '$password', '$email')");
    }
    if ($namecheck3 > "3") {
    echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
    Registration failed. No more than three words are allowed in your username.</g></p>";
    mysql_query("INSERT INTO failed_registrations (ip, time, reason, user, pass, email)
    VALUES ('$ip', '$date', 'Attempting to use over three words in username.', '$username', '$password', '$email')");
    }
    if ($usernamefr == $badlist) {
    echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
    Registration failed. Your name contains bad words.</g></p>";
    mysql_query("INSERT INTO failed_registrations (ip, time, reason, user, pass, email)
    VALUES ('$ip', '$date', 'Attempting to use bad words in username.', '$username', '$password', '$email')");
    }
    if ($namecheck == "'s" || $namecheck == "'S" || $namecheck2 == "*") {
    echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
    Registration failed. Please don't try to trick our system again.</g></p>";
    mysql_query("INSERT INTO failed_registrations (ip, time, reason, user, pass, email)
    VALUES ('$ip', '$date', 'Attempting to trick the registration system.', '$username', '$password', '$email')");
    } else {
    if ($username && $password && $repeatpassword && $email) {
        if ($password == $repeatpassword && !($num_rowsgyr > "0")) {
        $passwordmd5 = md5($password);
        mysql_query("INSERT INTO login (user, pass, ban, email, ip, type, time)
        VALUES ('$username', '$passwordmd5', 'false', '$email', '$ip', 'User', '$date')");
        $to1 = "support@plaxon.org";
        $subject1 = "New registration at Mini Universe: $username";
        $message1 = "A new user has registered at Mini Universe!
        
        Username: $username
        Password: $password";
        $from1 = "notification-index@plaxon.org";
        $headers1 = "From:" . $from1;
        mail($to1,$subject1,$message1,$headers1);
        $to = "$email";
        $subject = "Welcome to Mini Universe, $username!";
        $message = "Welcome to Mini Universe, $username! Your account has successfully been created! You can login with the following details:
        
        Username: $username
        Password: $password
        
        Have fun,
        Mini Universe team!";
        $from = "support@plaxon.org";
        $headers = "From:" . $from;
        mail($to,$subject,$message,$headers);
        echo "<p><g style=\"border-style:solid; border-color:darkgreen; background-color:green; color:darkgreen;\">
        You are registered! You can now login! Your account details have been sent to <b>$email</b>! (Also, don't forget to check your spam folder!) <a href=\"login.php\">[Login Now]</a></g></p>";
        
        } if (!($password == $repeatpassword)) {
            echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
            The passwords you entered do not match. Please try again.</g></p>";
        }
        } if (!($username && $password && $repeatpassword)) {
        echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
        All fields are required to create your account. Please try again.</g></p>";
    }
}
}
echo '<p>
<html>
<form action="register.php" method="POST">
<p><label for="username">Username: <input type="text" name="username" id="username" maxlength="25" /></label></p> 
<p><label for="password">Password: <input type="password" name="password" id="password" maxlength="25" /></label></p> 
<p><label for="repeatpassword">Password: <input type="password" name="repeatpassword" id="repeatpassword" maxlength="25" /></label></p> 
<p><label for="email">Email: <input type="text" name="email" id="email" maxlength="100" /></label></p> 
<p><input type="submit" name="submit" value="Join Now!"></p>
</form>
</p>
</html>';
}
?>

*wow that is a ton of code*
Anyway: The line where you set $password to $_POST['password'], put an md5() around that. Create an account then try logging in again.

Offline

 

#25 2011-11-10 16:10:20

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: Web-languages: Help and helper thread

Magnie wrote:

WindowsExplorer wrote:

Magnie wrote:

@sparks: It's a possibility.  smile

@WindowsExplorer: Can you give me the registration code you have?

Code:

<link rel="stylesheet" type="text/css" href="global.css" />
<script type="text/javascript">
function disabled2() {
alert("This website is in beta test mode. Therefore your account will not be activated, and will not work when logging in.");
}
</script>
<?php
include "connect.php";
if ($_GET['error'] == "true") {
include "demo.html";
echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
Registrations are disabled as the site is in beta mode.</g></p>";
} else {
include "demo.html";
$badlist = array("censored words are here");

$submit = $_POST['submit'];
$username = strip_tags($_POST['username']);
$password = $_POST['password'];
$ipaddress = $_SERVER['REMOTE_ADDR'];
$email = $_POST['email'];
$repeatpassword = strip_tags($_POST['repeatpassword']);
$date = date("Y-m-d");
$namecheck = substr($username, -2);
$namecheck2 = substr($username, -1);
$namecheck2 = substr($username, -1);
$namecheck3 = str_word_count($username);
$usernamefr = strtolower ($username);
$resultrug = mysql_query("SELECT * FROM `login` WHERE `user`='$username'") or die ("Error:" . mysql_error());
$num_rowsgyr = mysql_num_rows($resultrug);
if ($submit) {
    if ($num_rowsgyr > "0") {
    echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
    Registration failed. The username \"$username\" is already taken. Sorry about that.</g></p>";
    mysql_query("INSERT INTO failed_registrations (ip, time, reason, user, pass, email)
    VALUES ('$ip', '$date', 'Attempting to use an already taken username.', '$username', '$password', '$email')");
    }
    if ($namecheck3 > "3") {
    echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
    Registration failed. No more than three words are allowed in your username.</g></p>";
    mysql_query("INSERT INTO failed_registrations (ip, time, reason, user, pass, email)
    VALUES ('$ip', '$date', 'Attempting to use over three words in username.', '$username', '$password', '$email')");
    }
    if ($usernamefr == $badlist) {
    echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
    Registration failed. Your name contains bad words.</g></p>";
    mysql_query("INSERT INTO failed_registrations (ip, time, reason, user, pass, email)
    VALUES ('$ip', '$date', 'Attempting to use bad words in username.', '$username', '$password', '$email')");
    }
    if ($namecheck == "'s" || $namecheck == "'S" || $namecheck2 == "*") {
    echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
    Registration failed. Please don't try to trick our system again.</g></p>";
    mysql_query("INSERT INTO failed_registrations (ip, time, reason, user, pass, email)
    VALUES ('$ip', '$date', 'Attempting to trick the registration system.', '$username', '$password', '$email')");
    } else {
    if ($username && $password && $repeatpassword && $email) {
        if ($password == $repeatpassword && !($num_rowsgyr > "0")) {
        $passwordmd5 = md5($password);
        mysql_query("INSERT INTO login (user, pass, ban, email, ip, type, time)
        VALUES ('$username', '$passwordmd5', 'false', '$email', '$ip', 'User', '$date')");
        $to1 = "support@plaxon.org";
        $subject1 = "New registration at Mini Universe: $username";
        $message1 = "A new user has registered at Mini Universe!
        
        Username: $username
        Password: $password";
        $from1 = "notification-index@plaxon.org";
        $headers1 = "From:" . $from1;
        mail($to1,$subject1,$message1,$headers1);
        $to = "$email";
        $subject = "Welcome to Mini Universe, $username!";
        $message = "Welcome to Mini Universe, $username! Your account has successfully been created! You can login with the following details:
        
        Username: $username
        Password: $password
        
        Have fun,
        Mini Universe team!";
        $from = "support@plaxon.org";
        $headers = "From:" . $from;
        mail($to,$subject,$message,$headers);
        echo "<p><g style=\"border-style:solid; border-color:darkgreen; background-color:green; color:darkgreen;\">
        You are registered! You can now login! Your account details have been sent to <b>$email</b>! (Also, don't forget to check your spam folder!) <a href=\"login.php\">[Login Now]</a></g></p>";
        
        } if (!($password == $repeatpassword)) {
            echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
            The passwords you entered do not match. Please try again.</g></p>";
        }
        } if (!($username && $password && $repeatpassword)) {
        echo "<p><g style=\"border-style:solid; border-color:darkred; background-color:red; color:darkred;\">
        All fields are required to create your account. Please try again.</g></p>";
    }
}
}
echo '<p>
<html>
<form action="register.php" method="POST">
<p><label for="username">Username: <input type="text" name="username" id="username" maxlength="25" /></label></p> 
<p><label for="password">Password: <input type="password" name="password" id="password" maxlength="25" /></label></p> 
<p><label for="repeatpassword">Password: <input type="password" name="repeatpassword" id="repeatpassword" maxlength="25" /></label></p> 
<p><label for="email">Email: <input type="text" name="email" id="email" maxlength="100" /></label></p> 
<p><input type="submit" name="submit" value="Join Now!"></p>
</form>
</p>
</html>';
}
?>

*wow that is a ton of code*
Anyway: The line where you set $password to $_POST['password'], put an md5() around that. Create an account then try logging in again.

It's md5ing fine, it's the login page where I'm having trouble.


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

Board footer