Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 23-09-2005, 03:02 PM   #1 (permalink)
In The Zone
 
Join Date: Oct 2004
Posts: 437
Default [Help] With php project


i have been trying to make a php mis system from some weeks but i have been getting some error in each page which has been haulting the over all coding again and again.

so is(are) there are php expert ,helpful guy/gal who can help me to debug these files...
i am sure that for genius its just matter of some hours
so are ther any body who can help me ...
but to be frank i have not seen many php guy/gal here much any way lets hope....
its just a very simple and small project ..all coding has been done manually
(tested on easyphp) but only registration page is working
php mysql used..
thanks for help(if any body)
thanks
saha
if any body is such helpful please pm to me
__________________
be who u r :
Saharika is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 23-09-2005, 11:12 PM   #2 (permalink)
Human Spambot
 
tuxfan's Avatar
 
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
Default

I am not a PHP expert and I don't use PHP-MySQL. But I can try to help if you want. No guarantee of a solution.
__________________
:: Free hosting and free domain names available in special cases. Conditions apply ::
tuxfan is offline  
Old 23-09-2005, 11:45 PM   #3 (permalink)
Version 2.0
 
Deep's Avatar
 
Join Date: Jan 2004
Location: Mumbai
Posts: 977
Default

whats the error and paste the code...

Deep
__________________
- Deep Ganatra -
www.whoisdeep.com
www.twitter.com/DeepXP/
Deep is offline  
Old 23-09-2005, 11:55 PM   #4 (permalink)
Coming back to life ..
 
it_waaznt_me's Avatar
 
Join Date: Nov 2003
Location: A bit closer to heaven
Posts: 1,997
Default

Gee .. One more non expert here ..
__________________
Sleight of hand and twist of fate...
On a bed of nails she makes me wait...
And I wait without you ...
With or without you ..
----
Batty = Too Busy Now !!!
it_waaznt_me is offline  
Old 24-09-2005, 10:48 AM   #5 (permalink)
In The Zone
 
Join Date: Oct 2004
Posts: 437
Default

first error message it gives
Forbidden
You don't have permission to access /html/"view.php on this server.

the directory is not protected as other all files of the directory can be accessed easily with out any message

htaccess is also not used ...

the problem is used very peculiar...

full code
login.php
Code:
<?php 
ob_start();
//require_once ('includes/config.inc'); 
$page_title = 'Login';
if (isset($_POST['submit'])) { 
	require_once ('mysql_connect1.php'); 	
	if (empty($_POST['username'])) {
		$u = FALSE;


		echo '

<font color="red" size="+1">You forgot to enter your username!</font></p>';
	} else {
		$u = escape_data($_POST['username']);
	}
	
	if (empty($_POST['password'])) {
		$p = FALSE;
		echo '

<font color="red" size="+1">You forgot to enter your password!</font></p>';
	} else {
		$p = escape_data($_POST['password']);
	}
	
	if ($u && $p) { // If everything's OK.
	
		// Query the database.
		

$query = "SELECT user_id,name FROM students WHERE username='$u' AND password=PASSWORD('$p')";	
		$result = @mysql_query ($query);
		$row = mysql_fetch_array ($result); 
		
		if ($row) { 
				
				$_SESSION['name'] = $row[1];
				$_SESSION['user_id'] = $row[0];
			ob_end_clean();
 header ("Location:  http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) .
"\"view.php?aid={$row['user_id']}\">");
				exit();
			

	
		} else { // No match was made.
			echo '

<font color="red" size="+1">The username and password entered do not match those on file.</font></p>'; 
		}


		mysql_close(); 
		
	} else { 
		echo '

<font color="red" size="+1">Please try again.</font></p>';		
	}
	
} 
?>
<h1>Login</h1>


Your browser must allow cookies in order to login.</p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset>


User Name: <input type="text" name="username" size="10" maxlength="20" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /></p>


Password: <input type="password" name="password" size="20" maxlength="20" /></p>
<div align="center"><input type="submit" name="submit" value="Login" /></div>
</form>
view.php
Code:
<?
//require_once ('includes/config.inc'); 
require_once ('/mysql_connect1.php'); 
$page_title = 'view';
  	if (!isset($_SESSION['name'])) {
header ("Location:  http://" . $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']) . "/login.php");
exit();	
} 


else 
			{ 
		if (isset($_GET['uid'])) {
    $query = "SELECT * FROM students WHERE user_id = {$_GET['uid']}";
    $result=@mysql_query($query);

    		if (mysql_num_rows($result)) { // if there are any rows of data, fetch the data
        if (mysql_fetch_assoc($result)) {
        echo '

Name: ' . $row['name'] . '
';
      echo '

Email: ' . $row['email'] . '
';
        echo '

Address: ' . $row['address'] . '
';
        } else {
            echo '

No data returned!</p>';
        }
    } else {
        echo '

Student not found.</p>';
    }
} else {
    echo '

Missing uid!</p>';
}

			}
?>
whats the matter
i think the problem is with

header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) .
"\"view.php?aid={$row['user_id']}\">");
of login.php if i replace that view.php as index...or any other files just works fine...
all files are in one directory
html inside www
i am using easyphp 1-8 on windows...

the actual project is
1)the register page is working fine...loginpage and that view page has this problem ....

and other are teacer login and view which will be solved if this problem get solved as it uses same logic but only different table

2)other give assignment ...is a form connected to database ...and view assignment...is just same as view ..it retrieves assignment according to teacherid ...$_GET['tid']

3)and i have combo box for listing data of students table and next combo for listing teachers ...(i have not used seach)

so its just 3 good pages that will complete my application ...that also i have coded all just there are some errors so....

by the way have you seen this kind of application development in any books(i will buy them if locally available),sites (to printed)..or even rady made source code download...which might solve my problem.

any help
its just a test ...non commercial university project i am trying to develop

any php expert
saha
__________________
be who u r :
Saharika is offline  
Old 24-09-2005, 05:38 PM   #6 (permalink)
Coming back to life ..
 
it_waaznt_me's Avatar
 
Join Date: Nov 2003
Location: A bit closer to heaven
Posts: 1,997
Default

Code:
header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . 
"\"view.php?aid={$row['user_id']}\">");
Change that with :
Code:
header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . 
"/".view.php?aid={$row['user_id']}\">");
I havent gone throught the code though .. Try this one .. Ill see to it when I reach home..
__________________
Sleight of hand and twist of fate...
On a bed of nails she makes me wait...
And I wait without you ...
With or without you ..
----
Batty = Too Busy Now !!!
it_waaznt_me is offline  
Old 24-09-2005, 06:26 PM   #7 (permalink)
Version 2.0
 
Deep's Avatar
 
Join Date: Jan 2004
Location: Mumbai
Posts: 977
Default

Quote:
Originally Posted by it_waaznt_me
Code:
header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . 
"\"view.php?aid={$row['user_id']}\">");
Change that with :
Code:
header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . 
"/".view.php?aid={$row['user_id']}\">");
I havent gone throught the code though .. Try this one .. Ill see to it when I reach home..
batty saab kidhar?

there is something else wrong in the code bhai...

here is the correct code

Code:
header ("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/view.php?aid=".$row['user_id']."");
__________________
- Deep Ganatra -
www.whoisdeep.com
www.twitter.com/DeepXP/
Deep is offline  
Old 24-09-2005, 07:09 PM   #8 (permalink)
In The Zone
 
Join Date: Oct 2004
Posts: 437
Default

some guys are just unbelieveable
i think it is the solution but know what this problem was not solved by many so called experts for me.
all say permission errors....

any way thanks for answer...i dont believe mr bat ,how many things does he knows,hardware ,software ,now programming as well ...even it was not totally corret at least it shows he knows php...

any way thanks mr deep ..to be frank i have been thinking buying web space from you some day ..may be if i can make somedynamic sites myself some day ..i am in process....

any way whats about these..............
the actual project is
1)the register page is working fine...loginpage and that view page has this problem ....

and other are teacer login and view which will be solved if this problem get solved as it uses same logic but only different table

2)other give assignment ...is a form connected to database ...and view assignment...is just same as view ..it retrieves assignment according to teacherid ...$_GET['tid']

3)and i have combo box for listing data of students table and next combo for listing teachers ...(i have not used seach)

so its just 3 good pages that will complete my application ...that also i have coded all just there are some errors so....

by the way have you seen this kind of application development in any books(i will buy them if locally available),sites (to printed)..or even rady made source code download...which might solve my problem.

any help
its just a test ...non commercial university project i am trying to develop

so i think if help is to come from its mr bat or mr deep lets see if i can get some help...

well i will try to test those code now hope and pray its works...

thanks
may be i will contact you if i have further trouble....
__________________
be who u r :
Saharika is offline  
Old 24-09-2005, 07:28 PM   #9 (permalink)
In The Zone
 
Join Date: Oct 2004
Posts: 437
Default

could be revise the view page throughly to see if any thing is wrong there...
__________________
be who u r :
Saharika is offline  
Old 24-09-2005, 07:42 PM   #10 (permalink)
Version 2.0
 
Deep's Avatar
 
Join Date: Jan 2004
Location: Mumbai
Posts: 977
Default

Quote:
Originally Posted by Saharika
1)the register page is working fine...loginpage and that view page has this problem ....

and other are teacer login and view which will be solved if this problem get solved as it uses same logic but only different table
The solution I provided should fix that problem...


Quote:
Originally Posted by Saharika
2)other give assignment ...is a form connected to database ...and view assignment...is just same as view ..it retrieves assignment according to teacherid ...$_GET['tid']
hmm, this is also same as view.php you just need to change the variable, thats it...

Quote:
Originally Posted by Saharika
3)and i have combo box for listing data of students table and next combo for listing teachers ...(i have not used seach)
for this do foll. thing

Code:
while ($row = mysql_fetch_row[$result])
{
     $teacher_name = $row[0];
     $show_options. = "<option>$teacher_name</option>";
}
in html do this...

Code:
<select name="teachers" multiple>
<?php echo $show_options; ?>
</select>
so this will display teacher names in dropdown box

Quote:
Originally Posted by Saharika
by the way have you seen this kind of application development in any books(i will buy them if locally available),sites (to printed)..or even rady made source code download...which might solve my problem.

any help
its just a test ...non commercial university project i am trying to develop

so i think if help is to come from its mr bat or mr deep lets see if i can get some help...

well i will try to test those code now hope and pray its works...

thanks
may be i will contact you if i have further trouble....
This kind of custom code is very difficult to find but the you can easily find the code on the same outline, i..e fetching details from database and displaying in table, form etc....

I hope I have answered your question, I found it very difficult to understand so I just helped with whatever I could understand from your reply.

Regards
Deep
__________________
- Deep Ganatra -
www.whoisdeep.com
www.twitter.com/DeepXP/
Deep is offline  
Old 24-09-2005, 11:46 PM   #11 (permalink)
Coming back to life ..
 
it_waaznt_me's Avatar
 
Join Date: Nov 2003
Location: A bit closer to heaven
Posts: 1,997
Default

Ehe .. Did I miss that trailing > too ? .. Anyway I am a non expert na ..
__________________
Sleight of hand and twist of fate...
On a bed of nails she makes me wait...
And I wait without you ...
With or without you ..
----
Batty = Too Busy Now !!!
it_waaznt_me is offline  
Old 25-09-2005, 09:46 AM   #12 (permalink)
In The Zone
 
Join Date: Oct 2004
Posts: 437
Default not correct

it gives error

Parse error: parse error in c:\program files\easyphp1-8\www\html\login.php on line 37
now so i think its rather problem in that
i am very tired of this i have been hanging around this from 3 days ...
and may be some 10-15 post so may be the bext thing would be i would upload this files (just login,register and view and database sql file) that way the problem will be solved ...
i think if will be matter of five minutes for expert
so

Code:
<?php
ob_start();
$page_title = 'Login';
if (isset($_POST['submit'])) { 
require_once('../mysql_connect1.php'); 
	
	if (empty($_POST['username'])) { // 
		

$u = FALSE;
		echo '

<font color="red" size="+1">You forgot to enter your 

username!</font></p>';
	} else {
	$u =escape_data($_POST['username']);
	}
	
	

if (empty($_POST['password'])) {
		$p = FALSE;
		echo '

<font 

color="red" size="+1">You forgot to enter your password!</font></p>';
	} else {
		

$p = escape_data($_POST['password']);
	}
	
	if ($u && $p) { 
	
		

$query = "SELECT user_id,name FROM students WHERE username='$u' AND password=PASSWORD('$p')";	
	

	$result = @mysql_query ($query);
		$row = mysql_fetch_array ($result); 
		
		if ($row) { 
				
				

$_SESSION['name'] = $row[1];
				$_SESSION['user_id'] = $row[0];
		

	ob_end_clean();
				header ("Location: 

http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/that.php?aid=".$row['user_id']."")

;				exit();
				
		} else { 

// No match was made.
			echo '

<font color="red" size="+1">The username and 

password entered do not match those on file.</font></p>'; 
		}
		
		

mysql_close(); // Close the database connection.
		
	} else { // If everything 

wasn't OK.
		echo '

<font color="red" size="+1">Please try again.</font></p>';		
	}
	
} // End of SUBMIT conditional.
?>

<h1>Login</h1>


Your browser must allow 

cookies in order to login.</p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" 

method="post">
<fieldset>


User Name: <input type="text" name="username" size="10" 

maxlength="20" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /></p>


Password: <input type="password" name="password" size="20" maxlength="20" /></p>
<div 

align="center"><input type="submit" name="submit" value="Login" /></div>
</form><!-- End of Form 

-->
by the way where is that line number 37
can any body provide good help
thanks
__________________
be who u r :
Saharika is offline  
Old 25-09-2005, 10:28 AM   #13 (permalink)
Version 2.0
 
Deep's Avatar
 
Join Date: Jan 2004
Location: Mumbai
Posts: 977
Default

hmm I ran the same code but I didnt get any error...

may be you might have given some line breaks in comments or so...

here the code again...just copy and paste it..

Code:
<?php 
ob_start(); 
$page_title = 'Login'; 
if (isset($_POST['submit'])) { 
require_once('../mysql_connect1.php'); 
    
   if (empty($_POST['username'])) { // 
       

$u = FALSE; 
      echo '

<font color="red" size="+1">You forgot to enter your username!</font></p>'; 
   } else { 
   $u =escape_data($_POST['username']); 
   } 
    
    

if (empty($_POST['password'])) { 
      $p = FALSE; 
      echo '

<font color="red" size="+1">You forgot to enter your password!</font></p>'; 
   } else { 
       

$p = escape_data($_POST['password']); 
   } 
    
   if ($u && $p) { 
    
       

$query = "SELECT user_id,name FROM students WHERE username='$u' AND password=PASSWORD('$p')";    
    

   $result = @mysql_query ($query); 
      $row = mysql_fetch_array ($result); 
       
      if ($row) { 
             
             

$_SESSION['name'] = $row[1]; 
            $_SESSION['user_id'] = $row[0]; 
       

   ob_end_clean(); 
            header ("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/that.php?aid=".$row['user_id']."");            exit(); 
             
      } else { 

// No match was made. 
         echo '

<font color="red" size="+1">The username and password entered do not match those on file.</font></p>'; 
      } 
       
       

mysql_close(); // Close the database connection. 
       
   } else { // If everything wasn't OK. 
      echo '

<font color="red" size="+1">Please try again.</font></p>';       
   } 
    
} // End of SUBMIT conditional. 
?> 

<h1>Login</h1> 


Your browser must allow 

cookies in order to login.</p> 
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" 

method="post"> 
<fieldset> 


User Name: <input type="text" name="username" size="10" 

maxlength="20" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /></p> 


Password: <input type="password" name="password" size="20" maxlength="20" /></p> 
<div 

align="center"><input type="submit" name="submit" value="Login" /></div> 
</form>
Deep is offline  
Old 25-09-2005, 11:54 AM   #14 (permalink)
In The Zone
 
Join Date: Oct 2004
Posts: 437
Default

i noticed a thing suppose i copied all the code in new page login2.php
it gives username and password box but when i enter coorect uname and pass then the errors comes
Parse error: parse error in c:\program files\easyphp1-8\www\html\login.php on line 37

in address bar i can see
http://localhost/html/login.php
though i have started from
http://localhost/html/login2.php
so i think the problem is with view.php
not login.php
i think this part is also causing problem
if (!isset($_SESSION['name'])) {
header ("Location: http://" . $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']) . "/login.php");
exit();
but it says error is in line 37
is it so
even i do
http://localhost/html/view.phpuid=1
gives same problem
so i think problem is with view.php
the code i am using for view.php is
Code:
<?php
//require_once ('includes/config.inc'); 
require_once ('../mysql_connect1.php'); 
$page_title = 'view';
  	if (!isset($_SESSION['name'])) {
header ("Location:  http://" . $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']) . "/login.php");
exit();	
} 


else 
			{ 
		if (isset($_GET['uid'])) {
    $query ="SELECT * FROM students WHERE user_id ={$_GET['uid']}";
    $result=@mysql_query($query);

    		if (mysql_num_rows($result)) { // if there are any rows of data, fetch the data
        if (mysql_fetch_assoc($result)) {
        echo '

Name: ' . $row['name'] . '
';
      echo '

Email: ' . $row['email'] . '
';
        echo '

Address: ' . $row['address'] . '
';
        } else {
            echo '

No data returned!</p>';
        }
    } else {
        echo '

Student not found.</p>';
    }
} else {
    echo '

Missing uid!</p>';
}

			}
?>
this post is getting longer because of post
sorry ..may be after the things are fixed i will delete or edit some of my post ..
thanks for help
saha
__________________
be who u r :
Saharika is offline  
Old 27-09-2005, 12:28 AM   #15 (permalink)
Coming back to life ..
 
it_waaznt_me's Avatar
 
Join Date: Nov 2003
Location: A bit closer to heaven
Posts: 1,997
Default

Code:
header ("Location:  http://" . $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']) . "/login.php");
Change it to :
Code:
header ("Location:  http://" . $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']) . "/login2.php");
__________________
Sleight of hand and twist of fate...
On a bed of nails she makes me wait...
And I wait without you ...
With or without you ..
----
Batty = Too Busy Now !!!
it_waaznt_me is offline  
Old 27-09-2005, 12:31 AM   #16 (permalink)
Coming back to life ..
 
it_waaznt_me's Avatar
 
Join Date: Nov 2003
Location: A bit closer to heaven
Posts: 1,997
Default

Oh .. The issue is resolved Deep tells me ..
__________________
Sleight of hand and twist of fate...
On a bed of nails she makes me wait...
And I wait without you ...
With or without you ..
----
Batty = Too Busy Now !!!
it_waaznt_me is offline  
Old 27-09-2005, 12:33 AM   #17 (permalink)
Version 2.0
 
Deep's Avatar
 
Join Date: Jan 2004
Location: Mumbai
Posts: 977
Default

there were few problems in the code she was using, she had mailed me the files and I fixed them..

1st was she was passing wrong varilable name in hdear i.e. aid, it should have been uid

2nd - she had not started session in the view.php so view.php was redirecting to login.php back because it couldnt find session name

3rd she had not given proper conditions for queries in view.php

So after spending 1 hr or so on it..finally we fixed it but still sessions thing doesnt work on her machine but it works fine on my machine..

So for me it is 100% fixed but for her its not

Deep
__________________
- Deep Ganatra -
www.whoisdeep.com
www.twitter.com/DeepXP/
Deep is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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


 
Latest Threads
- by topgear
- by Charan

Advertisement




All times are GMT +5.5. The time now is 06:40 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2