Go Back   Computer Forums > Web Design | Website Development > Web Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 05-29-2006, 11:04 AM   #1
BSOD
 
MSFanBoy's Avatar
 
Join Date: May 2006
Posts: 190
Default Login script?

My login script suddenly stopped working after I started trying to incorporate md5...any ideas?

Code:
<center>
<?php

session_start();

// connect to the mysql database server.
include('inc/connect.php');

if ($_POST['username']) {
//did they supply a password and username
$username=$_POST['username'];
$pass=md5('$_POST['pass']')
if ($pass==NULL) {
echo "No password given.";
}else{
$query = mysql_query("SELECT username,pass FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($query);
if($data['pass'] != $pass) {
echo "The supplied login is incorrect";
}else{
$query = mysql_query("SELECT username,pass FROM users WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($query);
$_SESSION["s_username"] = $row['username'];
echo "You have successfully logged in as ".$_SESSION['s_username']." and can go to the index <a href='index.php'>here</a>.";
}
}
}
?>
<h1>Login</h1>
<form action='login.php' method='POST'>
<table style='border:1px solid #000000;'>
<tr>
<td align='right'>
Username: <input type='text' size='15' maxlength='25' name='username'>
</td>
</tr>
<tr>
<td align='right'>
Password: <input type='password' size='15' maxlength='25' name='pass'>
</td>
</tr>
<tr>
<td align='center'>
<input type="submit" value="Login">
</td>
</tr>
<tr>
<td align='center'>
<a href='register.php'>Register Here</a>
</td>
</tr>
</table>
</form>
</center>
This is the error:
Parse error: parse error, unexpected T_STRING in /home/tcp/public_html/dl/usersystem/login.php on line 12

And line 12 is this:
$pass=md5('$_POST['pass']')
__________________

MSFanBoy is offline   Reply With Quote
Old 05-29-2006, 11:33 AM   #2
BSOD
 
King of Kings's Avatar
 
Join Date: Mar 2006
Posts: 1,072
Default Re: Login script?

Well, if you want to use mine here.But this is a very basic script. It dosent connect so a server and just uses 1 pass.

Code:
<div class="fw-text"> <!-- ParagraphBodyStart --><td><font face="Trebuchet MS, Verdana, Arial" size="2"><!-- ParagraphBodyStart --><SCRIPT>
function passWord() {
var testV = 1;
var pass1 = prompt('Please Enter Your Password',' ');
while (testV < 3) {
if (!pass1) 
history.go(-1);
if (pass1.toLowerCase() == "password") {
alert('Access Granted');
window.open('http://');
break;
} 
testV+=1;
var pass1 = 
prompt('Access Denied','Password');
window.open('http://');
}
if (pass1.toLowerCase()!="password" & testV ==3) 
history.go(-1);
return " ";
} 
</SCRIPT>
<CENTER>
<FORM>
<input type="button" value="Enter Secret Area" onClick="passWord()">
</FORM>
</CENTER><!-- ParagraphBodyEnd --></font></td><!-- ParagraphBodyEnd --> </div>
__________________

King of Kings is offline   Reply With Quote
Old 05-29-2006, 11:38 AM   #3
BSOD
 
MSFanBoy's Avatar
 
Join Date: May 2006
Posts: 190
Default Re: Login script?

That would be impossible for me to use with a registration system...I need it to connect to a database and pull the encrypted passwords..etc...

Not to mention it's javascript

My script works fine without the md5 hash part.
MSFanBoy is offline   Reply With Quote
Old 05-30-2006, 05:21 AM   #4
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 8,004
Default Re: Login script?

$pass=md5('$_POST['pass']')

should be

$pass=md5('$_POST['pass']');

you missed the semi colon.
__________________
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 05-30-2006, 07:49 AM   #5
j03
~~~~~~~~
 
Join Date: Jan 2005
Location: Wales
Posts: 5,556
Send a message via MSN to j03
Default Re: Login script?

Why is MSfanBoy BAnned?
j03 is offline   Reply With Quote
Old 05-30-2006, 07:50 AM   #6
Daemon Poster
 
uid=[0]'s Avatar
 
Join Date: Apr 2006
Posts: 906
Send a message via Yahoo to uid=[0]
Default Re: Login script?

Quote:
Originally Posted by samurai
Why is MSfanBoy BAnned?
I was wondering the same thing... Look at his profile, then look at "All his posts" and you will see why.

http://computerforums.org/search.php?searchid=186678
__________________

__________________
"Security is nothing more than a thought that makes you sleep well at night." - Me
MCSE/MCSA
Security+/Network+
Wireless Network Security Spec.
uid=[0] is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 06:36 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0