Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Login php page not working in dw cs3

New Here ,
Apr 07, 2008 Apr 07, 2008

Hi!

I am new to php. I created a login (php5.2.5) page using dreamweaver cs3 with mysql database. I have added

the login user server behaviour. When I preview, the login page opens, i enter the username and password, but

the username and password is not validated and page not redirected, remains as it is. I get the following error

in the localhost.error.log:

PHP Warning: Cannot modify header information - headers already sent by (output started at C:\\Program

Files\\Apache Software Foundation\\Apache2.2\\htdocs\\PHPCLI\\main.php:1) in C:\\Program

Files\\Apache Software Foundation\\Apache2.2\\htdocs\\PHPCLI\\main.php on line 68, referer:

http://localhost/main.php

The page worked fine before adding login server behaviour.
Here is the code from main.php(created thru dw cs3). mysql database created thru phpmyadmin.

<?php virtual('/Connections/js.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;
}
}

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;
}
}

mysql_select_db($database_js, $js);
$query_jsrecord = "SELECT * FROM matrimony";
$jsrecord = mysql_query($query_jsrecord, $js) or die(mysql_error());
$row_jsrecord = mysql_fetch_assoc($jsrecord);
$totalRows_jsrecord = mysql_num_rows($jsrecord);
?>
<?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['profileid'])) {
$loginUsername=$_POST['profileid'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "/jsdirectory.php";
$MM_redirectLoginFailed = "/errorlogin.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_js, $js);

$LoginRS__query=sprintf("SELECT profileid, password FROM matrimony WHERE profileid=%s AND

password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $js) 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>
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
}
-->
</style></head>

<body>
<div id="main">
<div align="center">
<p> </p>
<form action="<?php echo $loginFormAction; ?>" method="POST" name="jsloginform" id="jsloginform">
<table width="100" border="1">
<tr>
<td><label for="profileid">profile id</label>
<input type="text" name="profileid" id="profileid" /></td>
</tr>
<tr>
<td><label for="password">password</label>
<input type="password" name="password" id="password" /></td>
</tr>
<tr>
<td><label for="submit"></label>
<input type="submit" name="submit" id="submit" value="Submit" /></td>
</tr>
</table>
</form>
<p> </p>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($jsrecord);
?>


Kindly help...
TOPICS
Server side applications
599
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 07, 2008 Apr 07, 2008
radhababu wrote:
> PHP Warning: Cannot modify header information - headers already sent by
> (output started at C:\\Program
>
> Files\\Apache Software Foundation\\Apache2.2\\htdocs\\PHPCLI\\main.php:1) in
> C:\\Program
>
> Files\\Apache Software Foundation\\Apache2.2\\htdocs\\PHPCLI\\main.php on line
> 68, referer:

"Headers already sent" is a common problem encountered by PHP beginners.
The DW Log In User server behavior uses the PHP header() function to
redirect the page after checking the username and password. There must
be no output to the browser before the call to header(). What confuses
beginners is that "output" includes even a single space or new line
character.

The error message suggests the problem is on line 68. Are you using echo
or anything like that? If so, that's the cause of your problem.

Another common cause is an extra line at the end of the connections
file. Open Connections/js.php, and make sure there are no extra lines
after the closing PHP tag. You can do this by looking at the line
numbers. Click as far down on the page as you can, and use backspace
until your cursor is directly to the right of the closing PHP tag.

One other possible cause is the use of links relative to the site root.
When you set that preference in your site definition, Dreamweaver uses
virtual() to include the connections file like this:

> <?php virtual('/Connections/js.php'); ?>

Try changing that to this:

<?php require_once('Connections/js.php'); ?>

Make sure the relative path to the file is correct.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 08, 2008 Apr 08, 2008
It worked! Thanks a lot for the help. I have been breaking my head over this, did not get a proper response from anyone.

The last option you had mentioned solved the problem. The problem was with the preference I set in the site definition. When I changed to the document option, virtual connection changed to require_once in the script and it worked!

Does this mean I have to work always with this setting?

Thanks once again!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 08, 2008 Apr 08, 2008
radhababu wrote:
> Does this mean I have to work always with this setting?

I don't know. Using virtual() seems to cause problems for some people.
In theory, it shouldn't, as long as the server runs PHP as an Apache
module. However, require_once always works, so it's the preferred option.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 24, 2008 Jun 24, 2008
Hi
I have deleted my question
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 01, 2008 Jul 01, 2008
LATEST
Why did you delete lol
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines