PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > macromedia.dyna.html > DW Log In User server behavior not working
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
DW Log In User server behavior not working

Réponse
 
LinkBack Outils de la discussion
Vieux 05/10/2008, 08h00   #1
MartyMatthews
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut DW Log In User server behavior not working

I created a user's table in MySQL using phpMyAdmin with four fields, name,
username, password, and level. I populated this table with four entries, again
with phpMyAdmin. Then in Dreamweaver I created a php page with a form with two
fields, "username" and "password," and a submit button. I then added the Log In
User server behavior with the obvious fields selections and it doesn't
work--nothing happens with Login is clicked. I have read Dreamweaver CS3 The
Missing Manual, and The Essential Guide To Dreamweaver CS3 with CSS, Ajax, and
PHP, and look though this forum. From all I read, I am doing all the correct
things. Below I have added the code page. I understand a lot of it, but not the
use of "accesscheck" in $loginFormAction. I also don't see how the submit
button is recognized.

Any would be appreciated.
Marty


<?php require_once('../Connections/archives.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
$theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ?
mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "editmenu.html";
$MM_redirectLoginFailed = "Editing.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_archives, $archives);

$LoginRS__query=sprintf("SELECT ipos2, ipos3 FROM ticks WHERE ipos2=%s AND
ipos3=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password,
"text"));

$LoginRS = mysql_query($LoginRS__query, $archives) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="<?php echo $loginFormAction; ?>" method="POST" name="form1">
Username:
<input name="username" type="text" size="30" /><br />
Password: <input name="password" type="text" size="20" /><br />
<input name="submit" type="button" value="Login" />
</form>
</body>
</html>


  Réponse avec citation
Vieux 05/10/2008, 16h00   #2
David Powers
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DW Log In User server behavior not working

MartyMatthews wrote:
> I created a user's table in MySQL using phpMyAdmin with four fields, name,
> username, password, and level. I populated this table with four entries, again
> with phpMyAdmin. Then in Dreamweaver I created a php page with a form with two
> fields, "username" and "password," and a submit button. I then added the Log In
> User server behavior with the obvious fields selections and it doesn't
> work--nothing happens with Login is clicked.


The clue almost certainly lies in the following code:

> $LoginRS__query=sprintf("SELECT ipos2, ipos3 FROM ticks WHERE ipos2=%s AND
> ipos3=%s",
> GetSQLValueString($loginUsername, "text"), GetSQLValueString($password,
> "text"));


The SQL query is looking for the values of ipos2 and ipos3 in a table
called ticks. Since you have got my book, check the screenshot at the
bottom of page 510. Table is set to users, and Username column and
Password column are set to the appropriate values. It looks as though
you have forgotten to change those settings in the Log In User dialog box.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
  Réponse avec citation
Vieux 06/10/2008, 20h24   #3
MartyMatthews
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DW Log In User server behavior not working

I replyed to this yesterday and don't know what happened to that. Here it is
again.

Thanks David! I find your book useful and well done. I've written a number of
computer books myself, so I don't say this lightly.

I'm not sure which settings you speaking about. The settings in my Log In User
dialog box are, from the top, form1, username, password, archives, ticks,
ipos2, ipos3, editmenu.html, Editing.php, Username and Password selected. What
specific settings would you change? Also, can you tell me how 'accesscheck' is
used in the $loginFormAction and how the Submit button is recognized?

Thanks Again,
Marty

  Réponse avec citation
Vieux 06/10/2008, 23h57   #4
David Powers
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DW Log In User server behavior not working

MartyMatthews wrote:
> The settings in my Log In User
> dialog box are, from the top, form1, username, password, archives, ticks,
> ipos2, ipos3, editmenu.html, Editing.php, Username and Password selected. What
> specific settings would you change?


I don't know, for the simple reason I don't know what your database
setup is like. The first three items make sense, but the next four look
very unusual - but maybe that's the way you have set everything up.

According to the list you have given, archives is the name of your MySQL
connection, ticks is the name of the database table, ipos2 is the
username column, and ipos3 is the password column. Are those really the
names you're using?

> Also, can you tell me how 'accesscheck' is
> used in the $loginFormAction and how the Submit button is recognized?


$loginFormAction is used as the value of the form's action attribute
like this:

action="<?php echo $loginFormAction; ?>"

The value of $loginFormAction is set by the following code:

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

The preceding code sets the value of $loginFormAction to the name of the
current URL. If the URL has a query string containing a variable called
accesscheck, that value is assigned to a session variable called
PrevUrl. As PrevUrl suggests, it's the URL of the previous page. To
understand how it works, you need to study the code in a page to which
the Restrict Access to Page server behavior has been applied.

If someone tries to access a restricted page without logging in, they
are redirected to the login page, and accesscheck is added to the query
string. If you select "Go to previous URL (if it exists)" in the Log In
User dialog box, the user is redirected automatically to the page stored
in accesscheck/PrevUrl as soon as the login succeeds.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
  Réponse avec citation
Vieux 07/10/2008, 22h34   #5
MartyMatthews
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DW Log In User server behavior not working

Thanks again for keeping with this. My MySQL database connection is 'archives,'
the table is 'ticks,' the username is 'ipos2,' and the password is 'ipos3.'
All of which, I think, are correct.I see no reason for this not working. When
Submit is clicked it does nothing. How is Submit recognized?

Marty

  Réponse avec citation
Vieux 07/10/2008, 23h58   #6
David Powers
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DW Log In User server behavior not working

MartyMatthews wrote:
> How is Submit recognized?


As I said before, the action attribute of the form is set to
$loginFormAction, which takes the value of $_SERVER['PHP_SELF']. In
other words, the form is submitted to the same page - it's self-processing.

To find out whether the form is being processed, you can use echo to
display the SQL query and its result onscreen. The following code is
taken from one of my login forms, so the query is different from yours,
but it shows where to add the debugging code.

$LoginRS__query=sprintf("SELECT username, pwd, admin_priv FROM users
WHERE username=%s AND pwd=%s",
GetSQLValueString($loginUsername, "text"),
GetSQLValueString($password, "text"));

// display the SQL query
echo $LoginRS__query . '<br />';

$LoginRS = mysql_query($LoginRS__query, $connAdmin) or
die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);

// display the number of rows found by the query
echo $loginFoundUser . '<br />';

Adding this debugging code will cause some warning messages to appear,
but that's not important. It should tell you whether the SQL query is
being processed.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
  Réponse avec citation
Vieux 08/10/2008, 02h11   #7
MartyMatthews
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DW Log In User server behavior not working

Thanks once more. I did add the echo statements and they displayed nothing. So
I looked at my input submit statement and found that while the name was submit,
the type was button, so it wan's doing anything. I changed the type to submit
and id = button, and it worked fine.

I appreciate your staying with this.

Marty Matthews

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h57.


Édité par : vBulletin® version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,22372 seconds with 15 queries