[Help] With php project

Status
Not open for further replies.

Saharika

In the zone
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
 

tuxfan

Technomancer
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.
 
OP
S

Saharika

In the zone
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:  *" . $_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>


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


[b]Password:[/b] <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:  *" . $_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: *" . $_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
 

it_waaznt_me

Coming back to life ..
Code:
header ("Location: *" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . 
"\"view.php?aid={$row['user_id']}\">");

Change that with :
Code:
header ("Location: *" . $_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..
 

Deep

Version 2.0
it_waaznt_me said:
Code:
header ("Location: *" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . 
"\"view.php?aid={$row['user_id']}\">");

Change that with :
Code:
header ("Location: *" . $_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: *".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/view.php?aid=".$row['user_id']."");
 
OP
S

Saharika

In the zone
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....
 

Deep

Version 2.0
Saharika said:
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...


Saharika said:
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...

Saharika said:
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

Saharika said:
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
 
OP
S

Saharika

In the zone
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: 

*".$_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>


[b]User Name:[/b] <input type="text" name="username" size="10" 

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


[b]Password:[/b] <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
 

Deep

Version 2.0
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: *".$_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> 


[b]User Name:[/b] <input type="text" name="username" size="10" 

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


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

align="center"><input type="submit" name="submit" value="Login" /></div> 
</form>
 
OP
S

Saharika

In the zone
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
*localhost/html/login.php
though i have started from
*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: *" . $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']) . "/login.php");
exit();
but it says error is in line 37
is it so
even i do
*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:  *" . $_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
 

it_waaznt_me

Coming back to life ..
Code:
header ("Location:  *" . $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']) . "/login.php");

Change it to :
Code:
header ("Location:  *" . $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']) . "/login2.php");

:p
 

Deep

Version 2.0
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
 
Status
Not open for further replies.
Top Bottom