Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1284
  • Last Modified:

Dreamweaver User Authentication with PHP and mySQL error

Hi, I have created a simple login form in Dreamweaver CS5 with Log In User server behavior. It connects with my sql database(which has table, username, and passwords), yet when I check it in live view there are 3 error messages on the page above the login(which doesnt work either). The messages are orange and read:
rning: virtual() [function.virtual]: Unable to include '/public_html/Connections/connIAL.php' - request execution failed in C:\wamp\www\Intellicom Website\login.php on line 1

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\wamp\www\Intellicom Website\login.php:1) in C:\wamp\www\Intellicom Website\login.php on line 37

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\Intellicom Website\login.php:1) in C:\wamp\www\Intellicom Website\login.php on line 37

Not sure what I am doing wrong here. I am fairly new to php and followed a tutuorial and everything seems like it should work. ANy suggestions? Thanks in advance
0
dshmed
Asked:
dshmed
  • 12
  • 12
  • 4
1 Solution
 
Jason C. LevineNo oneCommented:
Hi dshmed,

It looks like you have a bad path somewhere.  The errors are all caused by the PHP page's inability to find connIAL.php which it expects to be at:

/public_html/Connections/connIAL.php

My guess is you have the DW site paths defined incorrectly.
0
 
NeoAshuraCommented:
I must agree with Jason here, It looks liek to me that it cannot find the correct path name. if you do the following... on wamp...

find the wamp folder ( usually located on C:)

Then go into www folder. This is where all your php files are stored. Then navigate to the correct path of "connIAL.php" make sure the path it goes to is the same as the path in your code.

For testing purpose's you could always remove the connection at the top of your login page to the database and replace it with the code from your "connIAL.php" page. This way you would be able to see if that was indeed the problem.

I hope this help you if you need any help just ask.

If you are new to php i can also give advice on a few books which have helped me alot.

I can also provide you with login code and "login checking" code if that helps your situation with this problem.

Hope it gets solved soon.

Best Wishes.
0
 
dshmedAuthor Commented:
Thanks to both of you, I appreciate the help. Here is some additional info:

SIte Name: Intellicom Analytics
Local Site Folder: C:\wamp\www\Intellicom Website\

Remote Server Name: Intellicom Website
Connect Using: FTP
FTP Address: www.intellicom-endpointsreport.com
Username: commuoa5
Password: ********
Root directory: public_html
web URL: http://www.intellicom-endpointsreport.com/

Testing Server Name: local testing
Connect Using: Local/network
Server Folder: C:\wamp\www\Intellicom Website\
Web URL: http://localhost/Intellicom Website/

MySQL Connection Name: connLogin
MySQL server: localhost
User name: root
Password: none
Database: users

***When I test connection here it says Connection was made successfully***

My users.sql file location: C:\wamp\www\Intellicom Website\
My login.php(my php file with the login form) location: C:\wamp\www\Intellicom Website\
My connLogin location: C:\wamp\www\Intellicom Website\Connections
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Jason C. LevineNo oneCommented:
Your testing server is configured differently than your remote server (different paths) and thus DW is writing your include path the wrong way.

Do you actually have a different server for remote and testing or is this all one box?
0
 
dshmedAuthor Commented:
Hey Jason.

Again thanks for the input.  To be honest I'm not too sure. I have 2 servers listed in site setup, one remote, and one testing.  Is it unnecessary to have 2 separate servers?
0
 
Jason C. LevineNo oneCommented:
It depends on how your work more than anything else.  When you have two separate servers it makes thing a little more difficult in terms of file/version management and if the two servers have different paths it REALLY makes things difficult because you have to make sure that you correct paths when transferring from testing to remote.

I usually define the testing and remote servers to be the same thing if I cannot completely replicate the environment from one box to the next.
0
 
dshmedAuthor Commented:
Ok, that makes sense. I am not sure then what the server settings need to be in that case. Is it as simple\ as just clicking both the remote and testing boxes in the current server setup I had described earlier? Or are there things that need to be changed?  
0
 
Jason C. LevineNo oneCommented:
Yes, to make your live site your testing server, click both checkboxes in the Server dialog in  site setup and delete any servers that don't need to be there.  

However, you will still need to fix the misbehaving page above...DW will not fix the paths automatically.
0
 
dshmedAuthor Commented:
Does it make a difference whether I use phpmyadmin that I downloaded with WAMP or should I be using the phpmyadmin on my web host's cPANEL?
0
 
Jason C. LevineNo oneCommented:
One connects to a local database on your computer, the other connects a database on the web host.  So you should probably use the one on your web host unless you know how to synchronize databases between two mysql installations....
0
 
dshmedAuthor Commented:
Ok, so I set up my current remote server as my remote and testing server.  I added the following mySQL connection

MySQL Connection Name: connLogin
MySQL server: localhost
User name: commuoa5
Password: *********
Database: commuoa5_IALUsers

The database shows up and I can see the data when I expand it in database window. I add the Log In User Behavior and my preview in browser ends up like this:

Fatal error: Call to undefined function virtual() in /home7/commuoa5/public_html/login.php on line 1

My live view in DW looks like this:

= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();} //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 ); } } ?>
0
 
Jason C. LevineNo oneCommented:
What is line 1 in login.php?
0
 
dshmedAuthor Commented:
<?php virtual('/Connections/connLogin.php'); ?>
0
 
Jason C. LevineNo oneCommented:
Okay, your version of PHP may not support the virtual() function.

Try changing it to:

<?php require('Connections/connLogin.php'); ?>
0
 
dshmedAuthor Commented:
Tried it and in browser preview I am getting:

 Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home7/commuoa5/public_html/login.php:2) in /home7/commuoa5/public_html/login.php on line 37

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home7/commuoa5/public_html/login.php:2) in /home7/commuoa5/public_html/login.php on line 37

line 37 reads: session_start();
0
 
Jason C. LevineNo oneCommented:
Can you post all of the PHP code from that page, please.  
0
 
dshmedAuthor Commented:
<?php require('Connections/connLogin.php'); ?> 
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $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 = "/about.html";
  $MM_redirectLoginFailed = "/programs.html";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_connLogin, $connLogin);
  
  $LoginRS__query=sprintf("SELECT username, password FROM login WHERE username=%s AND password=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $connLogin) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
	if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
    //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 id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
  <p>Username
    <label for="username"></label>
    <input type="text" name="username" id="username" />
  </p>
  <p>Password
    <label for="password"></label>
    <input type="text" name="password" id="password" />
    <input type="submit" name="login" id="login" value="Submit" />
  </p>
</form>
</body>
</html>

Open in new window

0
 
Jason C. LevineNo oneCommented:
Move lines 36-38 to above line 3.  
0
 
dshmedAuthor Commented:
When I do that it inserts a second Log In User behavior and then says The Server Behavior panel cannot determine whether "Log in User" or "Log In User" is applied to your page.
0
 
Jason C. LevineNo oneCommented:
Don't worry about the Server Behavior Panel.  Does it work in the browser?
0
 
dshmedAuthor Commented:
it has the same warning session start error as before but ends with Line 4 instead of line 37
0
 
Jason C. LevineNo oneCommented:
Alright, revert it back to the way it was.  

Do you have any whitespace at the top or bottom of the code?  Sometimes that screws up PHP into thinking headers have already been sent.

Is this on your remote box or the WAMP installation?
0
 
NeoAshuraCommented:
Perhaps it would be wise im sure jason would agree to put error_reporting(E_ALL);  at the start before any code in every page to get more detailed errors.
0
 
NeoAshuraCommented:
Also, It may not make much difference but try transfering your files and database to easyPHP rather than wamp? its a portable version of WAMP basiclly. I used wamp and had loads of errors moved it to easyPHP and suddenly no more errors, i found that really strange...

also try posting your

connLogin.php

code here without the password etc.. for obv reasons.

Hopefully we will get this solved :)
0
 
NeoAshuraCommented:
Also i think start session should go at the top before any code. Not just above line 3.
0
 
dshmedAuthor Commented:
hey guys, thanks for the responses.  I finally got it.  Jason, you were riight I had  to change my script on line 1 to read <?php require('Connections/connLogin.php'); ?>  instead of <?php virtual(Connect...... i must have had a typo the first time I tried it.

Jason, thanks for sticking it out with me. I can finally move on to finishing this site (needs to be published by 4/1) so getting this accomplished now is huge for me.  

Thanks NeoAshura also for the input. I think I will look into EasyPHP as suggested, as this is not the first time I have encountered errors.

Take care guys and thanks again
0
 
dshmedAuthor Commented:
Very clear and thorough solution.
0
 
Jason C. LevineNo oneCommented:
dshmed,

Thanks for the kind words (and poinks).  

Just FYI, the built-in behaviors for DW are kind of crappy and lack features.  If you need to deploy a site fast and need more features or even better wizards, look into the WebAssist extensions (specifically: DataAssist, SecurityAssist, and Universal Email).  They will cost some extra money but will really extend your abilities until your coding skills catch up.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 12
  • 12
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now