General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 9th, 2003, 02:09 AM
dotcomma dotcomma is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: New Zealand
Posts: 20 dotcomma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question User input fields not "noticed"?

Hi,
I have a login form page which submits to login.php where I have some error checking. When the page loads, the first error message always gets displayed on screen. When I comment that part out, the secoond gets displayed.
When I comment out the whole page, I get a blank page.
At one stage, (can't remember how it happened - must have been when I was changing Apache / MySql / PHP versions) soomething else got displayed -- something like "this method is not allowed".
Hope this is clear enough.
Thanks for your help,
Toine

Reply With Quote
  #2  
Old December 9th, 2003, 11:10 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Nope, not clear enough. You'll need to post some code.

Reply With Quote
  #3  
Old December 9th, 2003, 11:45 AM
dotcomma dotcomma is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: New Zealand
Posts: 20 dotcomma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Here's the login form (on login.html):
PHP Code:
<form action="login.php" method="POST" name="frmLogin">
          <
table border="0" cellspacing="3" cellpadding="2" bgcolor="#999999">
            <
tr align="center"
              <
td
                <
p>Choose a Username:</p>
              </
td>
              <
td
                <
p>Choose a Password:</p>
              </
td>
              <
td
                <
p>Your Email:</p>
              </
td>
            </
tr>
            <
tr align="center"
              <
td
                <
input type="text" name="txtUsername" size="25">
              </
td>
              <
td
                <
input type="password" name="txtPassword" size="25">
              </
td>
              <
td
                <
input type="text" name="txtEmail" size="25">
              </
td>
            </
tr>
            <
tr align="center"
              <
td valign="top"colspan="3"><img src="images/spacer.gif" width="100" height="10"></td>
            </
tr>
            <
tr align="center">
              <
td valign="top"colspan="3"><img src="images/spacer.gif" width="100" height="5"></td>
            </
tr>
            <
tr align="center">
              <
td valign="top"colspan="3">
                <
input type="submit" name="login" value="Get Started!">
              </
td>
            </
tr>
          </
table>
        </
form

and this is login.php:
PHP Code:
<?PHP
//check that the user is calling the page from the login form and not accessing it directly 
//and redirect back to the login form if necessary 
if (!isset($txtUsername) || !isset($txtPassword))
{
echo 
'<h3>Username and password not set. <a href="login.html">Go back to login</a>.</h3>';
// header( "Location: login.html" ); 
exit();

//check that the form fields are not empty, and redirect back to the login page if they are 
elseif (empty($txtUsername) || empty($txtPassword) || empty($txtEmail))

echo 
'<h3>Username, Password and/or Email missing. Please <a href="login.html">go back</a> and make sure all boxes are filled in.</h3>';
// header( "Location: login.html" ); 
exit();

}else{ 

// Add slashes to the username, and make an md5 checksum of the password. 
$_POST['user'] = addslashes($_POST['txtUsername']); 
$_POST['pass'] = md5($_POST['txtPassword']); 
$_POST['email'] = $_POST['txtEmail'];

require(
"includes/db.php");

$user mysql_query("SELECT count(id) FROM tbluser WHERE usrUsername='$_POST[user]' AND usrPassword='$_POST[pass]'") or die("<b>Couldn't query the user-database.</b>");
$num mysql_result($user0); 

} if (!
$num) {

//if nothing is returned by the query, send to New User... 
header"Location: newuser.html" ); 
exit();

}else{

// Start the login session 
session_start();
// Registering the sessions
$_SESSION['user'] = $_POST['user']; 
$_SESSION['pass'] = $_POST['pass']; 
$_SESSION['email'] = $_POST['email']; 

// Set the cookie and redirect
setcookie("InstaWeb"$_SESSION['user']);

// Now we'll make sure the session has been registered
// by redirecting to the checkLogin page, from where
// the user will get redirected to Step One.
header('Location: checkLogin.php'); 
}
?>

The error message when I try to log in:
Quote:
Username and password not set. Go back to login.

When I start login.php with
PHP Code:
echo $_POST(txtUsername)'<br>';
echo 
$_POST(txtPassword)'<br>'

I get a completely blank page!
This seems to mean that the input fields get ignored...
Hope this is clearer
Any ideas? I have searched these forums for similar problems, but found none.
Any help would be greatly appreciated.
Thanks,
Toine

Reply With Quote
  #4  
Old December 9th, 2003, 03:20 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
My guess is that register_globals is turned off, so your initial if statement isn't getting the values of the form fields. Use $_POST["txtUsername"] and $_POST["txtPassword"] instead of just $txtUsername and $txtPassword. Also, in the echo statements you list, you're treating $_POST like a function. Use the same syntax I've used above and you should see a difference.

Reply With Quote
  #5  
Old December 9th, 2003, 07:46 PM
dotcomma dotcomma is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: New Zealand
Posts: 20 dotcomma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
That worked, thanks!
I must have restored the wrong version after my crash! Looks I've got a lot of re-work ahead of me...
Thanks,
Toine

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > User input fields not "noticed"?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway