Page 1 of 1
Access Denied
Posted: Sat Jun 21, 2003 6:35 pm
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
Posted: Sat Jun 21, 2003 6:39 pm
by rprins
What are the permissions on the file you are callng?
Posted: Sat Jun 21, 2003 10:30 pm
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.
Posted: Sat Jun 21, 2003 11:07 pm
by rprins
What does the php code look like, that might help.
Posted: Sat Jun 21, 2003 11:31 pm
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){
?>
<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
}
function check_form($f_name,$l_name,$email,$zip,$os){
if( !$l_name || !$email || !$zip ):
print("<h3>You are missing some required fields!</h3>");
if(!$l_name){
print("You need to fill in your: <b>Last Name</b>.<br>");}
if(!$email){
print("You need to fill in your: <b>Email</b>.<br>");}
if(!$zip){
print("You need to fill in your: <b>Zip</b>.<br>");}
print_form($f_name,$l_name,$email,$zip,$os);
else:
confirm_form($f_name,$l_name,$email,$zip,$os);
endif;
}
function confirm_form($f_name,$l_name,$email,$zip,$os){
?>
<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");
}
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>
Posted: Sun Jun 22, 2003 9:26 am
by ayron
you're missing a " in the form's action attribute
<form action="form_checker.php" ...
^
Posted: Sun Jun 22, 2003 9:53 am
by jcheema
Thanks. It worked.