/    Sign up×
Community /Pin to ProfileBookmark

My [URL=”http://iaccount.wizardsdnd.com/login.php”]login page[/URL] does not seem to work, because of incorrect code, despite the fact that Dreamweaver inserted the code, not me.

[CODE]<?php
@@UrlFormat@@(‘/Connections/iSphere.php’);

// *** Start the session
if (!session_id()) session_start();
// *** Validate request to log in to this site.
$FF_LoginAction = $HTTP_SERVER_VARS[‘PHP_SELF’];
if (isset($HTTP_SERVER_VARS[‘QUERY_STRING’]) && $HTTP_SERVER_VARS[‘QUERY_STRING’]!=””) $FF_LoginAction .= “?”.htmlentities($HTTP_SERVER_VARS[‘QUERY_STRING’]);
if (isset($HTTP_POST_VARS[‘Username’])) {
$FF_tmpUsername=$HTTP_POST_VARS[‘Username’];
$FF_tmpPassword=$HTTP_POST_VARS[‘Password’];
$FF_valUsername = (get_magic_quotes_gpc()) ? $FF_tmpUsername : addslashes($FF_tmpUsername);
$FF_valPassword = (get_magic_quotes_gpc()) ? $FF_tmpPassword : addslashes($FF_tmpPassword);
$FF_fldUserAuthorization=””;
$FF_redirectLoginSuccess=”/index.php”;
$FF_redirectLoginFailed=”/loginfail.php”;
$FF_rsUser_Source=”SELECT Username, Password “;
if ($FF_fldUserAuthorization != “”) $FF_rsUser_Source .= “,” . $FF_fldUserAuthorization;
$FF_rsUser_Source .= ” FROM Users WHERE Username='” . $FF_valUsername . “‘ AND Password='” . $FF_valPassword . “‘”;
mysql_select_db($database_iSphere, $iSphere);
$FF_rsUser=mysql_query($FF_rsUser_Source, $iSphere) or die(mysql_error());
$row_FF_rsUser = mysql_fetch_assoc($FF_rsUser);
if(mysql_num_rows($FF_rsUser) > 0) {
// username and password match – this is a valid user
$MM_Username=$FF_valUsername;
$HTTP_SESSION_VARS[‘MM_Username’] = $MM_Username;
session_register(“MM_Username”);
if ($FF_fldUserAuthorization != “”) {
$MM_UserAuthorization=$row_FF_rsUser[$FF_fldUserAuthorization];
} else {
$MM_UserAuthorization=””;
}
$HTTP_SESSION_VARS[‘MM_UserAuthorization’] = $MM_UserAuthorization;
session_register(“MM_UserAuthorization”);
if (isset($HTTP_SESSION_VARS[‘priorUrl’]) && true) {
$FF_redirectLoginSuccess = $HTTP_SESSION_VARS[‘priorUrl’];
}
mysql_free_result($FF_rsUser);
session_register(“FF_login_failed”);
$FF_login_failed = false;
$HTTP_SESSION_VARS[‘FF_login_failed’] = $FF_login_failed;
header (“Location: $FF_redirectLoginSuccess”);
exit;
}
mysql_free_result($FF_rsUser);
session_register(“FF_login_failed”);
$FF_login_failed = true;
$HTTP_SESSION_VARS[‘FF_login_failed’] = $FF_login_failed;
header (“Location: $FF_redirectLoginFailed”);
exit;
}
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<title>Login</title>
<link href=”/CSS/Preferences.css” rel=”stylesheet” type=”text/css” />
</head>

<body>
<div id=”wrapper”>
<div id=”container”>

<table width=”100%” border=”0″ cellpadding=”0″ cellspacing=”5″>
<form action=”<?php echo $FF_LoginAction?>” METHOD=”POST” name=”Login”>
<tr>
<td width=”50%” class=”label”>Username</td>
<td width=”50%” class=”input”><input name=”Username” type=”text” /></td>
</tr>
<tr>
<td width=”50%” class=”label”>Password</td>
<td width=”50%” class=”input”><input name=”Password” type=”password” /></td>
</tr>
<tr>
<td colspan=”2″ class=”button”><input name=”Login” type=”button” value=”Login” /></td>
</tr>
</form>
<tr>
<td width=”50%”>&nbsp;</td>
<td width=”50%”>&nbsp;</td>
</tr>
</table>

</div>
</div>
</body>
</html>[/CODE]

Can anyone see what is wrong?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@myminimonsterDec 22.2008 — Hi there,

I am new to php and mysql but I compared you code to mine.Sorry if I am talking rubbish or misleading you but maybe my inital thoughts are right.

The error seems to relate to the lines with '$database_iSphere' in them.

Have you already ran the code that connects you to your database?

On my code i connect to the database then run my query . here is a clip of my code.

<?php



$dbhost = "localhost";

$table = $_POST['town'];


$db = mysql_connect($dbhost, "yourdatabasename", "yourpassword") ;

if (!$db)

{

die('Could not connect: ' . mysql_error());

}

mysql_select_db("yourdatabasename",$db);


$sql="INSERT INTO ".$table." (town) VALUES ('".$town."')";

if (!mysql_query($sql,$db))

{

die('Error: ' . mysql_error());

}

echo "Database entry Submitted";mysql_close($db)

?>


I hope this helps and if I am taking ameturish i'm sorry

Adrian
Copy linkTweet thisAlerts:
@EpicKrisauthorJul 02.2009 — I've fixed this now, finally implemented a full login system with permissions.
×

Success!

Help @EpicKris 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.25,
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,
)...