/    Sign up×
Community /Pin to ProfileBookmark

whats wrong with this login script?

I’m getting a parse error…..

“Parse error: parse error, unexpected T_VARIABLE in D:LabDAQ Websiteintranetuserslogin.php on line 8

which is “$username = $_POST[‘username’];”

[code=php]<?php
include ( ‘includes/functions.inc’ );
include ( ‘includes/config.inc’ );
include ( ‘includes/sessmgmt.inc’ );
session_start();
dbConnect ()

$username = $_POST[‘username’];
$password = $_POST[‘password’];

$db = dbconnect() or die (“Error connecting to database.”);
$sql = “select * from security where user_name=’$username’ AND password=’$password'”;

$result = dbexecute($sql);

$rowCheck = dbexecute($result);
if($rowCheck > 0){
while($row = dbexecute($result)){

session_start();
session_register(‘username’);
echo ‘Success!’;
header( “Location: index.php” );
}
}
else {
echo ‘Incorrect login name or password. Please try again.’;
}
}

?> [/code]

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@crh3675Mar 02.2004 — Missing semicolon:

dbConnect () ;
Copy linkTweet thisAlerts:
@mikeyzcauthorMar 02.2004 — hmm..im still having problems now... Now the parse errors are gone, but when it tries to direct to the login.php which holds the sql and all i get a "page cannot be displayed error. below is my for code and below that is the new login.php code.....

[code=php]<%php
include ( 'includes/config.inc' );
include ( 'includes/functions.inc' );
dbConnect();
%>

<html>
<head>
<title>LabDAQ Remote v1.01</title>
<LINK REL=stylesheet HREF="style.css" TYPE="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</head>

<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">Welcome to the Remote LabDAQ ordering system. <br>
<strong>Please login below to begin ordering. </strong></div></td>
</tr>
</table>
<form name="frm_login" method="post" action="login.php">
<table width="208" border="1" align="center" bordercolor="000000">
<tr bgcolor="946699">
<td colspan="2" align="right" bordercolor="ffffff"><span class="style1">Login</span></span>&nbsp;<img src="images/lock.gif" width="12" height="13" border="0"></font> </td>
</tr>
<tr bordercolor="ffffff">
<td width="69%"><font class="login">Username</font></td>
<td width="31%">
<div align="center">
<input name="username" type="text" id="username" size="20" maxlength="10">
</div> </td>
</tr>
<tr bordercolor="ffffff">
<td width="69%"><font class="login">Password</font></td>
<td width="31%">
<div align="center">
<input name="password" type="password" id="password" size="20" maxlength="10">
</div> </td>
</tr>
<tr align="center" bordercolor="ffffff">
<td height="24" colspan="2" valign="middle">
<div align="right">
<input type="submit" value="Login" border=0>
</div></td>
</tr>
</table>
</form>
</body>
</html>
[/code]




[code=php]
<?php
include ( 'includes/config.inc' );
include ( 'includes/functions.inc' );
include ( 'includes/sessmgmt.inc' );

dbConnect ();

$username = $_POST['username'];
$password = $_POST['password'];

$sql = "select * from security where user_name='$username' AND password='$password'";

$result = dbexecute($sql);

$dbrowcount = dbexecute($result);

if($dbrowcount > 0){

while($dbrow = dbexecute($result)){

session_start();

session_register('username');

echo 'Success!';

header( "Location: index.php" );

}

}

else {

echo 'Incorrect login name or password. Please try again.';

}

?>[/code]
Copy linkTweet thisAlerts:
@crh3675Mar 02.2004 — You are calling the same functions for different results;

<i>
</i>$result = dbexecute($sql);

$dbrowcount = dbexecute($result); <br/>


Unless it's supposed to work that way
Copy linkTweet thisAlerts:
@mikeyzcauthorMar 02.2004 — okay, i had some extra crap in there that i didn't need. although now I am still getting "page cannot be displayed" when submitting the for to login.php


[code=php]
<?php
include ( 'includes/config.inc' );
include ( 'includes/functions.inc' );
include ( 'includes/sessmgmt.inc' );

dbConnect ();

$username = $_POST['username'];
$password = $_POST['password'];

$sql = "select * from security where user_name='$username' AND password='$password'";

$result = dbexecute($sql);


if($result > 0){

session_start();

session_register('username');

echo 'Success!';

header( "Location: index.php" );

}

else {

echo 'Incorrect login name or password. Please try again.';

}

?>

[/code]
Copy linkTweet thisAlerts:
@jpmoriartyMar 02.2004 — well also you cant send a header after you've outputted text. lose the echo on success and see what happens
Copy linkTweet thisAlerts:
@crh3675Mar 02.2004 — Ahhh! Contraire to the previous response, you can send the "Success!" before the header. Ues the ob_start tag.

<i>
</i>&lt;?php
include ( 'includes/config.inc' );
include ( 'includes/functions.inc' );
include ( 'includes/sessmgmt.inc' );

ob_start();
dbConnect ();

$username = $_POST['username'];
$password = $_POST['password'];

$sql = "select * from security where user_name='$username' AND password='$password'";

$result = dbexecute($sql);


if($result &gt; 0){

session_start(); <br/>
session_register('username'); <br/>
echo 'Success!'; <br/>
header( "Location: index.php" ); <br/>
}

else { <br/>
echo 'Incorrect login name or password. Please try again.'; <br/>
}

ob_end_flush();
?&gt;
Copy linkTweet thisAlerts:
@mikeyzcauthorMar 03.2004 — I actually ended up recoding a little and figured it out myself. I wish I would ahve seen these posts a little earlier. it would ahve saved me the trial and error time....LOL. here is what I finally came up with that works....

[code=php]

<?php
include ( 'includes/config.inc' );
//include ( 'includes/functions.inc' );
include ( 'includes/sessmgmt.inc' );

dbConnect ();


$username = $_POST['username'];

$password = $_POST['password'];


$sql = "select * from user_info where user_name='$username' AND password='$password'";


$rowcnt = dbGetRowCnt($sql);

if($rowcnt > 0){

session_start();
session_register('$username');
echo 'Success!';
}
else {

echo 'Incorrect login name or password. Please try again.';

}

?> [/code]
×

Success!

Help @mikeyzc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...