Skip to main content
Known Participant
December 11, 2007
Question

Log In User

  • December 11, 2007
  • 2 replies
  • 1183 views
Hello,

I am using Dreamweaver CS3 on a Mac running Apache 2.2. PHP 5.2.4 was pre-installed and I installed MySQL 5.0.45. I have tested these and everything seems to be ok.

I have created a site in DW which includes a login page (login.php). It has a simple form on it which displays the username and password fields and a submit button. If I display this page prior to adding the Log In User behaviour it displays no problem. However, as soon as I add the Log In User behaviour the page will not display in the browser. I have not modified the code added by the behaviour.

The following error message dislpays in Safari, but nothing is shown in Firefox:

Safari can't open the page " http://localhost/site/login.php". The error was: "cannot parse response" (NSURLErrorDomain:-1017).

I checked the error_log and it says:

[notice] Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7l DAV/2 PHP/5.2.4 configured - resuming normal operations

[notice] child pid 43266 exit signal Bus error (10)

Can anybody shed any light on this?


Cheers
This topic has been closed for replies.

2 replies

Inspiring
December 11, 2007
"The_Cardinal" <webforumsuser@macromedia.com> wrote in message
news:fjlqql$kv7$1@forums.macromedia.com...
> Hello,
>
> I am using Dreamweaver CS3 on a Mac running Apache 2.2. I have installed
> PHP
> 5.2.4 and MySQL 5.0.45. I have tested these installations and everything
> seems
> to be ok.
>
> I have created a site in DW which includes a login page (login.php). It
> has a
> simple form on it which displays the username and password fields and a
> submit
> button. If I display this page prior to adding the Log In User behaviour
> it
> displays no problem.
>
> However, as soon as I add the Log In User behaviour the page will not
> display
> in the browser. I have not modified the code added by the behaviour.

Quick check for bug in code: does the page contain session_start() after
adding the login behavior

Maybe your server might be configured to not show error messages, and you
aren't seeing the error message.

> Can anybody shed any light on this? Is there any error log I should
> provide?

Are you using a local testing server or hosting with a company?
If the latter you can ask them if it's possible to display the errors.
In either case if your HTTP server is Apache you may try to control the
error display by editing an .htaccess or PHP configuration file and
configuring the php error_reporting setting.

http://www.php.net/error_reporting

> Cheers

Inspiring
December 12, 2007


"The_Cardinal" <webforumsuser@macromedia.com> wrote in message
news:fjpa2f$lsu$1@forums.macromedia.com...
> Thanks for the reply.
>
> Here is the code that was added by the behaviour:
>
> <?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['passwrd'];
> $MM_fldUserAuthorization = "username";
> $MM_redirectLoginSuccess = "/~user/sitename/admin.php";
> $MM_redirectLoginFailed = "/~user/sitename/valerror.html";
> $MM_redirecttoReferrer = true;
> mysql_select_db($database_connXXXX, $connXXXX);
>
> $LoginRS__query=sprintf("SELECT username, password, username FROM Users
> WHERE username=%s AND password=%s",
> GetSQLValueString($loginUsername, "text"), GetSQLValueString($password,
> "text"));
>
> $LoginRS = mysql_query($LoginRS__query, $connEden) or
> die(mysql_error());
> $loginFoundUser = mysql_num_rows($LoginRS);
> if ($loginFoundUser) {
>
> $loginStrGroup = mysql_result($LoginRS,0,'username');
>
> //declare two session variables and assign them
> $_SESSION['MM_Username'] = $loginUsername;
> $_SESSION['MM_UserGroup'] = $loginStrGroup;
>
> if (isset($_SESSION['PrevUrl']) && true) {
> $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
> }
> header("Location: " . $MM_redirectLoginSuccess );
> }
> else {
> header("Location: ". $MM_redirectLoginFailed );
> }
> }
> ?>


Is that all the code?
I'm missing a connection include connEden.php

> As you can see, the code does contain session_start(). Is that a problem?
> I
> haven't modified the code in any way although I have removed my site name
> etc.
> from the code above for this post.

You need session_start on every page using sessions.

> The page is published to a local testing server and I have no problem with
> other php code, such as displaying records from a MySQL table. It is just
> the
> security stuff that is causing me problems.

the only thing I can see is the line-break between the GetSQLValueString and
the login Server Behavior participants,
this may prevent the redirect because all http headers must be sent before
any content.
Try removing

?>
<?php

> I have set error_reporting = E_ALL in the php.ini file so that I can see
> all
> errors during testing.

No errors at all?

Inspiring
December 16, 2007
I've ported all my files and database to my iMac and I am now seeing the following errors:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent on line 10

Warning: session_start() [function.session-start]: cannot send session cache limiter - headers already sent on line 10

Any ideas?

Also - any idea why I would see these errors on the iMac but not on my MacBook Pro? I copied the files from the MBP to the iMac, so the PHP and Apache config files are identical!

"The_Cardinal" <webforumsuser@macromedia.com> wrote in message
news:fk3m46$aq0$1@forums.macromedia.com...
> Should also have said that line 10 is: switch ($theType) {

Something before that line is generating output,
look for newlines between php tags

?> <-- there's a newline here
<?

change them to
?><?

Known Participant
December 11, 2007
I think you want the log in user behavior to be on the page the form redirects to, and not on the page with the form itself.

Glenn
Known Participant
December 11, 2007
No, I don't think so. the Log In behaviour goes on the page that the user types their username and password onto.

You use another behaviour to check the login credentials on the pages you wish to secure.