![]() |
![]() |
||||||
|
|||||||
| Tags: cs3, login, page, php, working |
![]() |
|
|||
|
:sad;
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... |
| Sponsored Links |
|
|||
|
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/ |
|
|||
|
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! |
|
|||
|
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/ |
|
|||
|
Hi
I have the same similar problem. My site worked well on a server with Apache Fedora. In local server with Windows Vista and IIS works well Now I have moved on Windows 2003 and procedure of login is not working There is created the MM_Username session. <?php require_once('../Connections/cnnSardadesign.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 = "livello"; $MM_redirectLoginSuccess = "login_si2.php"; $MM_redirectLoginFailed = "login_no.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_cnnSardadesign, $cnnSardadesign); $LoginRS__query=sprintf("SELECT Username, Password, livello FROM ****** WHERE Username=%s AND Password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $cnnSardadesign) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = mysql_result($LoginRS,0,'livello'); //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 ); } } ?> |
|
|||
|
The best prices for pills. ativan online , 189
cheap levitra , 6257 tramadol cod , 72839 cheap soma 9442 tenuate dospan |
|
|||
|
comment6, <a href=http://forums.invisionpower.com/index.php?sho wuser=134192>buy adipex</a>, buy adipex, buy adipex cheap - Viewing Profile buy adipex, pjcad,<a href=http://forums.invisionpower.com/index.php?sho wuser=134193>buy amoxicillin</a>, buy amoxicillin, Buy amoxicillin online - Viewing Profile buy amoxicillin, fdicv,<a href=http://forums.invisionpower.com/index.php?sho wuser=134194>buy diazepam</a>, buy diazepam, buy cheap diazepam - Viewing Profile buy diazepam, mloek,<a href=http://forums.invisionpower.com/index.php?sho wuser=134195>buy klonopin</a>,
buy klonopin, Buy klonopin online - Viewing Profile buy klonopin, volzp,<a href=http://forums.invisionpower.com/index.php?sho wuser=134196>xanax without prescription</a>, xanax without prescription, Xanax w o prescription - Viewing Profile xanax without prescription, inuys |
|
|||
|
post99, <a href=http://forums.invisionpower.com/index.php?sho wuser=134427>buy sildenafil</a>,
), buy sildenafil, )), Buy sildenafil online - Viewing Profile buy sildenafil, qyfuy, <a href=http://forums.invisionpower.com/index.php?sho wuser=134430>viagra no prescription</a>, ), viagra no prescription, )), V i a g r a no prescr - Viewing Profile viagra no prescription, shmtf |
|
|||
|
comment09, <a href=http://forums.invisionpower.com/index.php?sho wuser=134506>buy viagra</a>,
, cheap viagra, ;]]], Online Pharmacy - Viewing Profile buy viagra, anbeb |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise