Access Denied

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jcheema
Forum Newbie
Posts: 4
Joined: Sat Jun 21, 2003 6:35 pm

Access Denied

Post by jcheema »

I am new to HTML and PHP and hence my problem statement may not be very clear so kindly bear with me.

I have a PHP script form_checker.php which dispalys and validates a form. The action attribute of the form tag calls the form_checker.php itself. However when I submit the form I get the following message:

Forbidden
You don't have permission to access /form_checker.php" on this server
--------------------------------------------------------------------------------
Apache/2.0.44 (Win32) Server at localhost Port 80

I will appreciate any help.

Regards,
Cheema
User avatar
rprins
Forum Commoner
Posts: 31
Joined: Sat Jun 21, 2003 5:46 pm

Post by rprins »

What are the permissions on the file you are callng?
jcheema
Forum Newbie
Posts: 4
Joined: Sat Jun 21, 2003 6:35 pm

Post by jcheema »

I am using Windows XP Home Edition so haven't made any special efforts to change any permissions. Also I am accessing the same file from the browser without any problem. The access is denied only when the file is called by the "action" attribute of the form.
User avatar
rprins
Forum Commoner
Posts: 31
Joined: Sat Jun 21, 2003 5:46 pm

Post by rprins »

What does the php code look like, that might help.
jcheema
Forum Newbie
Posts: 4
Joined: Sat Jun 21, 2003 6:35 pm

Post by jcheema »

The code is:

Code: Select all

<HTML>
	<HEAD>
		<TITLE>Contact Info checker</TITLE>
	</HEAD>
	<BODY bgcolor="FFFFFF">
	<?php
					function print_form($f_name,$l_name,$email,$zip,$os)&#123;
?>			
				<form action=form_checker.php" method="POST">
					<table cellspacing="2" cellpadding="2" border="1">
						<tr>
							<td>First Name</td><td><input type="text" name="f_name" value="<?php print $f_name ?>"></td>
						</tr>
						<tr>
							<td>Last Name<b>*</b></td><td><input type="text" name="l_name" value="<?php print $l_name ?>"></td>
						</tr>
						<tr>
							<td>Email Address<b>*</b></td><td><input type="text" name="email" value="<?php print $email?>"></td>
						</tr>
						<tr>
							<td>Zip Code<b>*</b></td><td><input type="text" name="zip" value="<?php print $zip ?>"></td>
						</tr>
						<tr>
							<td>Operating System</td><td><input type="text" name="os" value="<?php print $os ?>"></td>
						</tr>
					</table>
					<input type="submit" name ="submit" value="Submit!"><input type="Reset">
				</form>
<?php
&#125;
	
									   
					function check_form($f_name,$l_name,$email,$zip,$os)&#123;
								if( !$l_name || !$email || !$zip ):
											print("<h3>You are missing some required fields!</h3>");
											if(!$l_name)&#123;
														print("You need to fill in your: <b>Last Name</b>.<br>");&#125;
											if(!$email)&#123;
														print("You need to fill in your: <b>Email</b>.<br>");&#125;
											if(!$zip)&#123;
														print("You need to fill in your: <b>Zip</b>.<br>");&#125;
										
     			print_form($f_name,$l_name,$email,$zip,$os);
     			else:
     						confirm_form($f_name,$l_name,$email,$zip,$os);
     			endif;
     &#125;				
					function confirm_form($f_name,$l_name,$email,$zip,$os)&#123;
?>
					<h2>Thanks! Below is the Information which you have sent us.</h2>
					<b>Contact Info</b>
<?php					
								print("<br>$f_name $l_name<br>$email<br>Email: $zip<br>OS: $os\n");
     &#125;
     if(!$submit):
?>
									<h3>Please Enter your Information</h3>
									Fields with a "<b>*</b>" are required.<p>
<?php
					print_form("","","","","","");
					else:									     
     				check_form($f_name,$l_name,$email,$zip,$os);
     endif;
?>				
	<HTML>
	<HEAD>
ayron
Forum Newbie
Posts: 14
Joined: Tue Jun 03, 2003 11:18 pm
Location: Perth, Australia

Post by ayron »

you're missing a " in the form's action attribute

<form action="form_checker.php" ...
^
jcheema
Forum Newbie
Posts: 4
Joined: Sat Jun 21, 2003 6:35 pm

Post by jcheema »

Thanks. It worked.
Post Reply