Adobe Dreamweaver Forums



Last 10 THreads :         compilation error (Last Post : Murray *ACE* - Replies : 2 - Views : 3 )           »          Give a checkbox a variable name. (Last Post : NedWebs - Replies : 2 - Views : 3 )           »          Is there an easier or neater way to code this... (Last Post : twistedpancreas - Replies : 0 - Views : 1 )           »          A New Joke Website (Last Post : nightwolf666 - Replies : 6 - Views : 7 )           »          Flash Player 10, problem with emdended fonts andattachment (Last Post : plasmaflex - Replies : 2 - Views : 3 )           »          DWCS4 Effects>Appear on DIV background image? (Last Post : Murray *ACE* - Replies : 4 - Views : 5 )           »          flash and wide-gamut monitors (Last Post : tonton66 - Replies : 1 - Views : 3 )           »          creating links between Fireworks images (Last Post : Murray *ACE* - Replies : 4 - Views : 5 )           »          CS4 Div Tags Help Needed (Last Post : Murray *ACE* - Replies : 6 - Views : 7 )           »          absolute images (Last Post : Murray *ACE* - Replies : 1 - Views : 2 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Dreamweaver: Main > Dreamweaver General
 
Tags: , , , ,



Reply
  #1 (permalink)  
Old 09-03-2008, 09:13 PM
smiffy47
 
Posts: n/a
Diggs:
Default Problem with Log in User dialogue box

I have been trying to set up a simple login page with the use of the Server
Behaviours on DWMX2004.
I can get it to make a page with the ability to check username(already input
into the form from a database) and password, and redirect to the next page.
However the problem comes when I try to defne a parameter to be passed on to
the next page. Then it wites code that results in a browser error message
before the login page is even loaded. When I use the "parameter" addition on
the "Log in User" dialogue box DW really gets its knickers in a twist and
produces code where the code gets confused with the comment, and even after
seperating them fails to operate. Here is the offending section as produced by
DW:

Can someone point out what changes are required to get the page to load and
the value of "organ" passed on to next page after submission of the password,
please? Thanks.

if (isset($_POST['cel_org'])) {
$loginUsername=$_POST['cel_org'];
$password=$_POST['cel_pw'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "../org_changechoice.php?organ=<?php echo
$row_rstLog['cel_org']; ?>
"; $MM_redirectLoginFailed ="login_park.php?organ=<?php echo
$row_rstLog['cel_org']; ?>"; $MM_redirecttoReferrer = false;
mysql_select_db($database_tormented3, $tormented3);
$LoginRS__query=sprintf("SELECT cel_org, cel_pw FROM cel_contents WHERE
cel_org='%s' AND cel_pw='%s'", get_magic_quotes_gpc() ? $loginUsername :
addslashes($loginUsername), get_magic_quotes_gpc() ? $password :
addslashes($password)); $LoginRS = mysql_query($LoginRS__query, $tormented3) or
die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if
($loginFoundUser) { $loginStrGroup =""; //declare two session variables and
assign them $GLOBALS['MM_Username'] = $loginUsername; $GLOBALS['MM_UserGroup']
= $loginStrGroup; //register the session variables
session_register("MM_Username"); session_register("MM_UserGroup"); if
(isset($_SESSION['PrevUrl'])&&false) { $MM_redirectLoginSuccess =
$_SESSION['PrevUrl']; } header("Location:". $MM_redirectLoginSuccess ); } else
{ header("Location:". $MM_redirectLoginFailed ); } } ?>



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-03-2008, 11:42 PM
Mark A. Boyd
 
Posts: n/a
Diggs:
Default Re: Problem with Log in User dialogue box

smiffy47 posted in macromedia.dreamweaver:

> Can someone point out what changes are required to get the page
> to load and the value of "organ" passed on to next page after
> submission of the password, please? Thanks.
>

Try removing all those external <?php ?> in that block of code that is
already inside those tags.

if (isset($_POST['cel_org'])) {
$loginUsername=$_POST['cel_org'];
$password=$_POST['cel_pw'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess =
"../org_changechoice.php?organ=$row_rstLog['cel_org']";
$MM_redirectLoginFailed
="login_park.php?organ=$row_rstLog['cel_org']";
$MM_redirecttoReferrer = false;
mysql_select_db($database_tormented3, $tormented3);
etc...


--
Mark A. Boyd
Keep-On-Learnin'
Reply With Quote
  #3 (permalink)  
Old 09-03-2008, 11:42 PM
Mark A. Boyd
 
Posts: n/a
Diggs:
Default Re: Problem with Log in User dialogue box

Mark A. Boyd posted in macromedia.dreamweaver:

> smiffy47 posted in macromedia.dreamweaver:
>
>> Can someone point out what changes are required to get the page
>> to load and the value of "organ" passed on to next page after
>> submission of the password, please? Thanks.
>>

> Try removing all those external <?php ?> in that block of code
> that is already inside those tags.


That was supposed to be extra, not external:

Try removing all those extra <?php ?> in that block of code that is
already inside those tags.
>
> if (isset($_POST['cel_org'])) {
> $loginUsername=$_POST['cel_org'];
> $password=$_POST['cel_pw'];
> $MM_fldUserAuthorization = "";
> $MM_redirectLoginSuccess =
> "../org_changechoice.php?organ=$row_rstLog['cel_org']";
> $MM_redirectLoginFailed
> ="login_park.php?organ=$row_rstLog['cel_org']";
> $MM_redirecttoReferrer = false;
> mysql_select_db($database_tormented3, $tormented3);
> etc...
>
>




--
Mark A. Boyd
Keep-On-Learnin'
Reply With Quote


  #4 (permalink)  
Old 09-04-2008, 07:16 AM
smiffy47
 
Posts: n/a
Diggs:
Default Re: Problem with Log in User dialogue box

Thanks Mark.
No that doesn't help.
Frustratingly I seem to be going backwards! Yesterday DW wrote me code that at
least redirected me to a chosen page as a result of my completion of the "Log
in User" dialogue box, even if it would not do so when I specified a parameter.
Today I have tried recreating that small sucess and the page fails to redirect
at all, simply representing itself with empty text fields.
I guess I better start with overcoming this issue before trying to deal with
the parameter one.
The code DW provides for the simple redirect is

if (isset($_POST['cel_org'])) {
$loginUsername=$_POST['cel_org'];
$password=$_POST['cel_pw'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "../org_changechoice.php";
$MM_redirectLoginFailed = "../org_list.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_tormented3, $tormented3);

$LoginRS__query=sprintf("SELECT cel_org, cel_pw FROM cel_contents WHERE
cel_org='%s' AND cel_pw='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername),
get_magic_quotes_gpc() ? $password : addslashes($password));

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

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

//register the session variables
session_register("MM_Username");
session_register("MM_UserGroup");

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>

It gives rise to the url:

http://localhost/torment_new/up_cont...k=%2Ftorment_n
ew%2Fup_content%2Forg_changechoice.php

whereas I am hoping for url
http://localhost/torment_new/up_cont...angechoice.php

Can you see why I am getting this output?

Thanks for taking an interest.

Reply With Quote
  #5 (permalink)  
Old 09-04-2008, 08:15 PM
Mark A. Boyd
 
Posts: n/a
Diggs:
Default Re: Problem with Log in User dialogue box

smiffy47 posted in macromedia.dreamweaver:

> Thanks Mark.
> No that doesn't help.

[...]

Fair notice: I haven't used DW's built-in behaviors for anything
related to database or PHP.

>
> if (isset($_POST['cel_org'])) {
> $loginUsername=$_POST['cel_org'];
> $password=$_POST['cel_pw'];
> $MM_fldUserAuthorization = "";
> $MM_redirectLoginSuccess = "../org_changechoice.php";
> $MM_redirectLoginFailed = "../org_list.php";
> $MM_redirecttoReferrer = false;
> mysql_select_db($database_tormented3, $tormented3);
>
> $LoginRS__query=sprintf("SELECT cel_org, cel_pw FROM
> cel_contents WHERE
> cel_org='%s' AND cel_pw='%s'",
> get_magic_quotes_gpc() ? $loginUsername :
> addslashes($loginUsername),
> get_magic_quotes_gpc() ? $password : addslashes($password));


Dreamweaver writes that? Since you're using MySQL, I would convert that
to use mysql_real_escape_string() instead of addslashes(). Likewise for
wherever your INSERT call may be.

http://us.php.net/manual/en/function...ape-string.php

> $LoginRS = mysql_query($LoginRS__query, $tormented3) or
> die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS);
> if ($loginFoundUser) {
> $loginStrGroup = "";
>
> //declare two session variables and assign them
> $GLOBALS['MM_Username'] = $loginUsername;
> $GLOBALS['MM_UserGroup'] = $loginStrGroup;
>
> //register the session variables
> session_register("MM_Username");
> session_register("MM_UserGroup");


That is out of date. As long as you have session_start(); at the very
beginning of your script, you can use:
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

And, unless the script requires it somewhere else, I would scrap those
$GLOBALS['...']=whatever lines.

> if (isset($_SESSION['PrevUrl']) && false) {
> $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
> }
> header("Location: " . $MM_redirectLoginSuccess );
> }
> else {
> header("Location: ". $MM_redirectLoginFailed );
> }
> }
> ?>


You should use a full URL for header().
http://us.php.net/header

For portability, you can utilize $_SERVER['HTTP_HOST']. Something like:

$myHost = "http://{$_SERVER['HTTP_HOST']}";
$MM_redirectLoginSuccess = "$myHost/org_changechoice.php";
$redirectLoginFailed = "$myHost/org_list.php";

(adjust for proper path if needed)

> It gives rise to the url:
>
> http://localhost/torment_new/up_cont...hp?accesscheck
> =%2Ftorment_n ew%2Fup_content%2Forg_changechoice.php
>
> whereas I am hoping for url
> http://localhost/torment_new/up_cont...angechoice.php
>
> Can you see why I am getting this output?


No. I don't see where any parameters are getting appended to those
location variables at all.

As long as you're testing on your dev machine (localhost), set your
php.ini file to show all errors.

error_reporting = E_ALL
display_errors = On


--
Mark A. Boyd
Keep-On-Learnin'
Reply With Quote
Reply


Thread Tools
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

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



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 01:43 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk