Login trouble

This is a discussion on "Login trouble" within the PHP Forum section. This forum, and the thread "Login trouble are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Dec 17th, 2007, 15:46
New Member
Join Date: May 2007
Location: uk
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Login trouble

Hey Everyone,

I'm having trouble creating a login page for my database.

Whenever I enter the correct username and password I receive this error message:

Warning: require_once(../mysql_connect.php) [function.require-once]: failed to open stream: No such file or directory in c:\Inetpub\wwwroot\new site\ropdunpw.php on line 200

Fatal error: require_once() [function.require]: Failed opening required '../mysql_connect.php' (include_path='.;C:\php5\pear') in c:\Inetpub\wwwroot\new site\ropdunpw.php on line 200

The php connect file is outside the main directory for security.
My php code is as follows:

PHP: Select all

<?php 
if (isset($_POST['submit'])) {
 require_once (
'../mysql_connect.php');
 function 
escape_data ($data) {
  global 
$dbc;
  if (
ini_get('magic_quotes_gpc')) {
   
$data stripslashes($data);
  }
  return 
mysql_real_escape_string($data$dbc);
 }
 
$message NULL;
 if (empty(
$_POST['username'])) {
  
$u FALSE;
  
$message .= '<p>You forgot to enter your username!</p>';
 } else {
  
$u escape_data($_POST['username']);
 }
 if (empty(
$_POST['password'])) {
  
$p FALSE;
  
$message .= '<p>You forgot to enter your password!</p>';
 } else {
  
$p escape_data($_POST['password']);
 }
 
 if (
$u && $p) { // If everything's OK.
  
$query "SELECT user_id FROM users WHERE username='$u' AND password=PASSWORD('$p')";  
  
$result = @mysql_query ($query);
  
$row mysql_fetch_array ($resultMYSQL_NUM); 
  if (
$row) { 
    
    
// Start the session, register the values & redirect.
    
session_start();
    
//$_SESSION['first_name'] = $row[1];
    
$_SESSION['user_id'] = $row[0];
    
header ("Location:  http://" $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "./index.php");
    exit();
    
  } else {
   
$message '<p>The username and password entered do not match those on file.</p>'
  }
  
mysql_close();
 } else {
  
$message .= '<p>Please try again.</p>';  
 }
}
$page_title 'Login';
//include ('../templates/header.inc');
if (isset($message)) {
 echo 
'<font color="red">'$message'</font>';
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset><legend class="main">Enter your information in the form below:</legend>
</br>
<p class="main"><b>User Name:</b> <input type="text" name="username" size="18" maxlength="20" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /></p>
<p class="main"><b>Password:</b> <input type="text" name="password" size="20" maxlength="20"<?php if (isset($_POST['password'])) echo $_POST['password']; ?> /></p>
</br>
<div align="center"><input type="submit" name="submit" value="Login" /></div>
</fieldset></form>
I've been stuck on this forever.
Any help would be great!

cheers
zig.

Last edited by c010depunkk; Dec 17th, 2007 at 16:54. Reason: please use [PHP] tags when posting PHP
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Dec 17th, 2007, 15:51
Aso's Avatar
Aso Aso is offline
Moderator

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 1,341
Blog Entries: 2
Thanks: 11
Thanked 49 Times in 46 Posts
Re: Login trouble

The problem isropdunpw.phpcannot acquire your mysql_connect.php file. Are you sure it is in the correct location? And named exactly as quoted in ropdunpw.php?
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Dec 18th, 2007, 02:38
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Login trouble

If you have it outside the main directory, use th absolute path the file to avoid PHP using the wrong base dir to find it.

PHP: Select all

require_once ('all/the/way/to/mysql_connect.php'); 

Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Having trouble with PHP voodoo465 PHP Forum 5 Feb 20th, 2007 21:47
CGI Trouble Maverick25r Other Programming Languages 0 Jul 31st, 2006 18:24
browser trouble killaclown55 Web Page Design 2 May 2nd, 2006 05:18
Trouble Getting Site Up M.K.Russ. PHP Forum 0 Apr 17th, 2006 15:59
Site trouble HELP Money_Mike$$ Web Page Design 7 Jan 18th, 2006 12:38


All times are GMT. The time now is 06:14.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42