Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

samgwatts

macrumors newbie
Original poster
Mar 26, 2008
21
0
Hi, I'm pulling the last few strands of my hair out with this problem.
I'm working on a MAC with APACHE PHP and MYSQL through the MAMP software. I'm developing a site http://universalmaritime.com and i have come across the white screen of death problem on the login page. (login is at the bottom of the slide show on the homepage)
This is the code in dreamweaver at the top of the login page that is giving me the problem i think.

<?php require_once('Connections/USERS.php'); ?>
<?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 = "admin_home.php";
$MM_redirectLoginFailed = "error.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_USERS, $USERS);

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

$LoginRS = mysql_query($LoginRS__query, $USERS) 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']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>

Does anybody have the faintest idea of what the problem may be cause i don't. I just want this very simple log in page to work. OR is there a way to create an admin page with one username and password where databases are not involved. PLEASE HELP ME!!!!

THANKS ALOT:confused:
 

Volante

macrumors regular
Feb 8, 2008
205
0
A blank screen is probably due to MAMP not displaying php errors as default. You can change this by editing MAMP/conf/php5/php.ini in your applications folder.

Search for display_errors in php.ini and change it to:
display_errors = On

Then restart your apache server.
 

samgwatts

macrumors newbie
Original poster
Mar 26, 2008
21
0
Thanks for your quick reply,

I have tried doing that but it won't give me permissions!!! even on my own machine!!! How do i get round this?

Thanks
 

wrldwzrd89

macrumors G5
Jun 6, 2003
12,110
77
Solon, OH
There are several solutions to this problem.

The Terminal way:

  • Use sudo to become the root user
  • Edit the file with your favorite command-line editor

The half-Terminal way:

  • Use sudo to become the root user
  • Use the open command to open TextEdit (or your favorite GUI editor)

The non-Terminal way:

  • Make a copy of the file in a place you have write permissions (e.g. your Desktop)
  • Edit the file with your favorite editor
  • Overwrite the original with the edited copy - Finder will ask you for your password
 

samgwatts

macrumors newbie
Original poster
Mar 26, 2008
21
0
Thanks for your reply wrldwzrd89,
I managed to get into the PHP.ini file and changed errors to ON but i see no errors displayed in the browser of my login page. http://www.universalmaritime.com/admin_page.php. I have restarted the MAMP server. Where else could the errors for this blank screen problem be?

Sorry for being a pain!
 

wrldwzrd89

macrumors G5
Jun 6, 2003
12,110
77
Solon, OH
Thanks for your reply wrldwzrd89,
I managed to get into the PHP.ini file and changed errors to ON but i see no errors displayed in the browser of my login page. http://www.universalmaritime.com/admin_page.php. I have restarted the MAMP server. Where else could the errors for this blank screen problem be?

Sorry for being a pain!
Check your logs - the error, if there was one, is probably in there.
 

samgwatts

macrumors newbie
Original poster
Mar 26, 2008
21
0
My logs in the MAMP folder show as follows:

For mysql errors:
080326 13:58:33 [Warning] You have forced lower_case_table_names to 0 through a command-line option, even though your file system '/Applications/MAMP/db/mysql/' is case insensitive. This means that you can corrupt a MyISAM table by accessing it with different cases. You should consider changing lower_case_table_names to 1 or 2
080326 13:58:33 [Warning] One can only use the --user switch if running as root
080326 13:58:34 InnoDB: Started; log sequence number 0 43665
080326 13:58:34 [Note] /Applications/MAMP/Library/libexec/mysqld: ready for connections.
Version: '5.0.41' socket: '/Applications/MAMP/tmp/mysql/mysql.sock' port: 8889 Source distribution.

My PHP errors :
[21-Mar-2008 11:01:20] PHP Notice: Undefined variable: loginFormAction in /Users/Sambo/Web/Universal site/admin_page.php on line 226

My apache errors:
authentication ...
[Wed Mar 26 13:58:34 2008] [notice] Digest: done
[Wed Mar 26 13:58:34 2008] [notice] Apache/2.0.59 (Unix) PHP/4.4.7 DAV/2 configured -- resuming normal operations


Are these any help to anyone??
 

wrldwzrd89

macrumors G5
Jun 6, 2003
12,110
77
Solon, OH
My logs in the MAMP folder show as follows:

For mysql errors:
080326 13:58:33 [Warning] You have forced lower_case_table_names to 0 through a command-line option, even though your file system '/Applications/MAMP/db/mysql/' is case insensitive. This means that you can corrupt a MyISAM table by accessing it with different cases. You should consider changing lower_case_table_names to 1 or 2
080326 13:58:33 [Warning] One can only use the --user switch if running as root
080326 13:58:34 InnoDB: Started; log sequence number 0 43665
080326 13:58:34 [Note] /Applications/MAMP/Library/libexec/mysqld: ready for connections.
Version: '5.0.41' socket: '/Applications/MAMP/tmp/mysql/mysql.sock' port: 8889 Source distribution.

My PHP errors :
[21-Mar-2008 11:01:20] PHP Notice: Undefined variable: loginFormAction in /Users/Sambo/Web/Universal site/admin_page.php on line 226

My apache errors:
authentication ...
[Wed Mar 26 13:58:34 2008] [notice] Digest: done
[Wed Mar 26 13:58:34 2008] [notice] Apache/2.0.59 (Unix) PHP/4.4.7 DAV/2 configured -- resuming normal operations


Are these any help to anyone??
Code:
[21-Mar-2008 11:01:20] PHP Notice:  Undefined variable: loginFormAction in /Users/Sambo/Web/Universal site/admin_page.php on line 226
That, right there, is the cause of your problem. You're trying to reference a variable called loginFormAction before it's been defined.
 

samgwatts

macrumors newbie
Original poster
Mar 26, 2008
21
0
Well done for spotting the problem, so how do i go about sorting it out. If you can imagine i'm looking at my login page i created in dreamweaver and connected to the mysql database, what should be done to the username and password form i created.

Thanks for you help
 

samgwatts

macrumors newbie
Original poster
Mar 26, 2008
21
0
Remember this all works fine in my testing server but i get the blank screen when i post it up to the web.
 

Volante

macrumors regular
Feb 8, 2008
205
0
That's two different web enviroments then, with different settings.

Again, it's the error handling. On the server you're uploading to, notices are resulting in errors that' kills the script. Also the blank page is on the server is probably result of display_erros being off, you probably have some sort of error_log on the server as well. Please check your php-settings on the server. This can be done by uploading a simple script:
phpinfo.php
<?php
phpinfo();
?>

You can fix the error by either:
A. Fixing the notice in the phpscript.
B. Changing settings in php.ini on the servers to:
error_reporting = E_ALL & ~E_NOTICE
C. Setting error_reporting in the phpscript:
error_reporting(E_ALL ^ E_NOTICE);
 

samgwatts

macrumors newbie
Original poster
Mar 26, 2008
21
0
Ok I think i Follow you.
so would i upload the sript:
phpinfo.php
<?php
phpinfo();
?>

on the login page i created, which would give me php settings for the server when i upload the file to the web. right?

I also need to contact my server admin to change error display to ON?

basically your saying its not a problem my end but with my server administrator?

Sam
 

wrldwzrd89

macrumors G5
Jun 6, 2003
12,110
77
Solon, OH
Ok I think i Follow you.
so would i upload the sript:
phpinfo.php
<?php
phpinfo();
?>

on the login page i created, which would give me php settings for the server when i upload the file to the web. right?

I also need to contact my server admin to change error display to ON?

basically your saying its not a problem my end but with my server administrator?

Sam
The problem IS on your end. Changing these settings would make it easier for you to figure out what is going on on the web server end.
 

samgwatts

macrumors newbie
Original poster
Mar 26, 2008
21
0
RIGHT, I have an error!!

this is what it says:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /Users/Sambo/Web/Universal site/admin_page.php:5) in /Users/Sambo/Web/Universal site/admin_page.php on line 9

Is this any help?
 

samgwatts

macrumors newbie
Original poster
Mar 26, 2008
21
0
I'm about to pick up my mac and throw through a window!!

Hi All
I REALLY hope someone can help me. They will be a God/Goddess if they can.

My problem:
I am developing a website and my client wants a login page which has just one username and password so members of his company can login using the same user name and password and download stuff from the private section.
I'm on a Mac running Apache, Mysql, PHP through MAMP. I have created a database in MAMP of a username and password and have created the login form in dreamweaver. A mysql connection has been made to the database and i have attached the "log in user" server behavior which gives me the following in the Actions box of the form i made <?php echo $loginFormAction; ?>

When i test it on my testing server its fine and works perfectly, when i test it on the web, all i get is a blank screen - nothing!

I then enabled errors in my PHP.ini files and got some code.

I now get the following code in my testing server and still nothing on the web.

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /Users/Sambo/Web/Universal site/admin_page.php:2) in /Users/Sambo/Web/Universal site/admin_page.php on line 6
session_start();

I have tried putting the session_start() at the top of the page but i still get a blank page when i upload.

The code on the page in dreamweaver is as follows:


PHP:
<?php require_once('Connections/userslogin.php'); ?>
<?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 = "admin_home.php";
  $MM_redirectLoginFailed = "error.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_userslogin, $userslogin);
  
  $LoginRS__query=sprintf("SELECT username, password FROM users WHERE username='%s' AND password='%s'",
    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
   
  $LoginRS = mysql_query($LoginRS__query, $userslogin) 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 );
  }
}
?>


Please can someone help me with this problem. Its been giving me problems for days.

Thanks alot!
Sam
 

ruckus

macrumors regular
Oct 19, 2005
180
0
This happens when you try to output text to the browser before the session_start() command. Be sure to also check your included file, userlogin.php.

I know this one is tricky it took me awhile to figure out too. It was a long time ago so I am not sure how much help i can be.

But maybe make sure your session_start() happens first before anything else happens?
 

samgwatts

macrumors newbie
Original poster
Mar 26, 2008
21
0
Ok, I have moved the start_sessions() to the top which gets rid of the warning error. When i try and log in on the testing server i now get the following error on the login page

Warning: Cannot modify header information - headers already sent by (output started at /Users/Sambo/Web/Universal site/admin_page.php:2) in /Users/Sambo/Web/Universal site/admin_page.php on line 38
session_start();
 

ruckus

macrumors regular
Oct 19, 2005
180
0
I believe its the same problem happening all over your code. Take some time to go through and make sure the session isn't open after you have started outputting to the browser.
 

samgwatts

macrumors newbie
Original poster
Mar 26, 2008
21
0
My userslogin.php (in my connections file) script is displaying some errors.
They are as follows:

PHP:
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_userslogin = "localhost";
$database_userslogin = "users";
$username_userslogin = "root";
$password_userslogin = "root";
$userslogin = mysql_pconnect($hostname_userslogin, $username_userslogin, $password_userslogin) or trigger_error(mysql_error(),E_USER_ERROR); 
?>

Any Ideas??
 

Mitthrawnuruodo

Moderator emeritus
Mar 10, 2004
14,424
1,065
Bergen, Norway
Are you using UTF-8 text encoding? If so: you may try setting it to "UTF-8, no BOM" and not just UTF-8.

Some servers go completely nuts if you don't (while others doesn't seem to mind). I struggled a while with this when we begun migrating stuff to our own server a while back...
 

samgwatts

macrumors newbie
Original poster
Mar 26, 2008
21
0
Hi,
Yes I' am using UTF-8_Unicode_ci. MAMP doesn't give me the option to use "no Bom"
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.