Why doesn't "$_SERVER['PHP_SELF']" in action= work for me.
I'm trying to make a form "self post", and was referred to the explanation at www.html-form-guide.com. I coded my page exactly as shown there, and even copied/pasted the action= code (simple as it is) to my form tag.
In my XAMPP test environment the submit yields:
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster (who would he be in a localhost environment?)
Error 403
When I tested on my Yahoo web hosting server, submit yieded:
The web page cannot be found.
The most likely causes are:
etc. etc.
Here's the code;
The following is placed at the top of the page immediately before the <html> tag:
<?php
// the following was to write the post info to a file to verify that this code was being executed - never happened.
$out = $_SERVER['PHP_SELF'];
$fho = fopen(C:\xampp\htdocs\iod\testphpself.txt,wt);
fwrite($fho,$out);
fclose($fho);
if (isset($_POST['submit']))
$fstname = $_POST['firstname'];
$midinit = $_POST['midinitial'];
$lastname = $_POST['lastname'];
$milen = (strlen($midinit));
if ($milen == 0)
{$fullname = $fstname." ".$lastname;}
else
{$fullname = $fstname." ".$midinit". ".$lastname;}
echo "Information has been stored for : $fullname <br /><br />";
The following is the <form> code:
<form name="form1" method="post" action="<?php echo $SERVER['PHP_SELF']; ?>">
Most of the above I gleaned from www.html-form-guied.com/php-form/php-form-action-self.html.
PLEASE! Can someone tell me where my error(s) is/are? I feel that I must be doing something wrong, but have no idea what it might be.
