There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot computer connection crash css dell drive driver drivers email error ethernet excel explorer firefox firefox 3 freeze game hard drive internet internet explorer itunes laptop malware monitor network networking nvidia outlook outlook 2003 outlook express partition printer problem problems router slow sound startup trojan usb video virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Desperate need of PHP help


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
cj_white's Avatar
Senior Member with 335 posts.
 
Join Date: Oct 2001
06-Mar-2004, 09:50 AM #1
Desperate need of PHP help
ok here is my problem. i have a website i created on godaddy.com. i have a survey form with questions. i initially wanted the answers emailed to me but godaddy has the mail() function disabled. i was then forced to insert the answers into a database provided. i created a login system where i can login, create new users and display the results of the survey. i created this on my computer. i am running apache 2 , PHP 4.31 and mysql 4.0.4. the entire app works fine on my server but whne i upload it and log in i get a white page. the only info i changed in my scripts before upload was the server info and database info. my first script is below

<?php
//check for required fields from the form
if ((!$HTTP_POST_VARS[username]) || (!$HTTP_POST_VARS[password])) {
header("Location:log_in.php");
exit;
}

//create session id
$sessionid=$HTTP_POST_VARS[username];

//connect to server and select database
$conn = mysql_connect("servername", "username", "password") or die(mysql_error());
mysql_select_db("database",$conn) or die(mysql_error());

//create and issue the query
$sql = "select username from users where username = '$HTTP_POST_VARS[username]' AND password=('$HTTP_POST_VARS[password]')";
$result = mysql_query($sql,$conn) or die(mysql_error());

//get the number of rows in the result set; should be 1 if a match
if (mysql_num_rows($result) == 1) {

//start session if logged in
session_start();
$HTTP_SESSION_VARS['auth_user']= $sessionid;
header("Location:menu.php");
}
else
{
//display message if not authorized
echo "You Are Not Authorized";
exit;
}
?>

it is fairly simple and straight forward. when you log in the form posts to this script. i know it is interacting with the db because if i put in the wrong username or password i get the not aauthorized message. i have ried taking out all the session info out and it still won't work. i think maybe they have something i need disabled. if anyone is interested here is a link to there phpinfo()

http://ftphelp.secureserver.net/linux-phpinfo.html

if someone has an idea of whats wrong i would sure appreciate the help.

thanks in advance
deuce868's Avatar
Senior Member with 638 posts.
 
Join Date: Nov 2000
Location: MI
06-Mar-2004, 10:15 AM #2
A couple of things. If you can log in and then just get a white page then something with the redirect must not be right. Since you get a bad username page it must only be with the good page. I don't see anything really wrong though so check your menu.php page. Make sure it is in the same folder and working fine without any login stuff.

Another thought..try changing your query. I think you need the ' in the array.

$sql = "select username from users where username = '" . $HTTP_POST_VARS['username'] . "' AND password=('" . $HTTP_POST_VARS['password'] . "')";

On another note I wanted to suggest some clean up of the code. You can use $_POST['var'] and $_SESSION['var'] instead of the HTTP_SESSION_VARS['..... it's a bit shorter and cleaner.
__________________
www.ricksweb.info
www.2webheads.com
Quote:
Techies just think a little differently...at least that's what they keep telling me.
cj_white's Avatar
Senior Member with 335 posts.
 
Join Date: Oct 2001
06-Mar-2004, 10:52 AM #3
if i delete all the session control code i can get to the menu page fine if i type it in the address bar.

here is the code for menu.php

<?php

session_start();
if(!isset($HTTP_SESSION_VARS['auth_user']))
{
header("Location:log_in.php");
}
?>

<html>
<head>
<title>The Grove Theater</title>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"></head>
<body BGCOLOR="003366">
<table WIDTH="65%" BORDER="0" ALIGN="CENTER" CELLPADDING="12" CELLSPACING="5">
<tr>
<td BGCOLOR="3366cc">
<div ALIGN="CENTER">
<h2><font FACE="Arial, Helvetica, sans-serif">Admin Main Menu</font></h2>
</div></td>
</tr>
<tr>
<td BGCOLOR="#FFFFFF">
<div ALIGN="CENTER"><font FACE="Arial, Helvetica, sans-serif"><a HREF="create_user.php" TITLE="Create New User">Create
New User</a></font></div></td>
</tr>
<tr>
<td BGCOLOR="#3366CC">
<div ALIGN="CENTER"><font FACE="Arial, Helvetica, sans-serif"><a HREF="view_answers.php" TITLE="View Survey Answers">View
Survey Answers</a></font></div></td>
</tr>
<tr>
<td BGCOLOR="#FFFFFF">
<div ALIGN="CENTER"><font FACE="Arial, Helvetica, sans-serif"><a HREF="logout.php" TITLE="Log Out">Log
Out</a></font></div></td>
</tr>
<tr>
<td BGCOLOR="#3366CC">
<div ALIGN="CENTER"><font FACE="Arial, Helvetica, sans-serif"></font></div></td>
</tr>
<tr>
<td BGCOLOR="#FFFFFF">
<div ALIGN="CENTER"><font FACE="Arial, Helvetica, sans-serif"></font></div></td>
</tr>
<tr>
<td BGCOLOR="#3366CC">
<div ALIGN="CENTER"><font FACE="Arial, Helvetica, sans-serif"></font></div></td>
</tr>
<tr>
<td BGCOLOR="#FFFFFF">
<div ALIGN="CENTER"><font FACE="Arial, Helvetica, sans-serif"></font></div></td>
</tr>
</table>
</body>
</html>


the thing that gets me is that it works just fine on my server but not on theirs. is there another way i can redirect besides the header()?
deuce868's Avatar
Senior Member with 638 posts.
 
Join Date: Nov 2000
Location: MI
06-Mar-2004, 10:56 AM #4
there is a header refresh I usually prefer to use. It doesn't give you the whole error if you hit back about (there is post data that will be submitted again) or something like that.

Check for some things like case sensitivity as their server is probably linux and case sensitive and if yours is windows it won't be.
__________________
www.ricksweb.info
www.2webheads.com
Quote:
Techies just think a little differently...at least that's what they keep telling me.
cj_white's Avatar
Senior Member with 335 posts.
 
Join Date: Oct 2001
06-Mar-2004, 05:00 PM #5
which particular functions are case sensitive?
deuce868's Avatar
Senior Member with 638 posts.
 
Join Date: Nov 2000
Location: MI
06-Mar-2004, 05:19 PM #6
All variables & functions in php are case sensitive. I am more worried about file names. For instance Log_IN.php and log_in.php would both work on a windows server, but it would not load correctly on a case sensitive server like linux.
cj_white's Avatar
Senior Member with 335 posts.
 
Join Date: Oct 2001
06-Mar-2004, 05:21 PM #7
well i finally figured out what was wrong. i had whitespace before and after my php tags on all my scripts. i read this post on php.net

header
Rob
04-Mar-2004 07:29
Watch out for whitespace char's outside your <? ?> block, also in your include files. Easy to overlook, but they make the "header" function fail, cause the newline/space/whatever will be seen as header info too.

i did not know that but now i do. thanks deuce for your help i never would have figured it out if you wouldn't have pointed me towards the redirect prob
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 07:22 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.