View previous topic :: View next topic |
Author |
Message |
RTAdams89 -
Joined: 06 Nov 2005 Posts: 102
|
Posted: Tue Mar 28, 2006 2:44 am Post subject: Dyanmic 404 page |
|
|
I have created a PHP 404 error page. It works fine when someone goes directly to it:
http://rtadams89.dyndns.org:9555/404.php
However, when a user opens a nonexistent page (And abyss redirects them to the 404.php page) the submission forum does not work. Try:
http://rtadams89.dyndns.org:9555/2.tss <--- Non-existent file
I think this has something to do with the way PHP is calling the self function and the way abyss handles 404 redirects, but other than that I'm lost. here is my php code:
Code: |
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Language" CONTENT="en-us">
<TITLE>Not Found (404)</TITLE>
<SCRIPT LANGUAGE="JavaScript">
if(parent.frames.length>=1)
{ window.top.location.href="index.html"
}
</SCRIPT>
</HEAD>
<BODY>
<P ALIGN="center"><B><FONT SIZE="5">Error 404: Not Found</FONT></B></P>
<P ALIGN="left">
<IMG BORDER="0" SRC="/pic15.jpg" ALIGN="left" WIDTH="244" HEIGHT="244">
</P>
<P ALIGN="left"> </P>
<P ALIGN="left"><B>Homer ate the page you were looking for. Ok, Ok, he didn't eat
it, but we can't find it right now either. The page may have been moved or
deleted, or you may have entered the address wrong. Try again, and if you still
have a problem, enter your name below and press the "Send" button to report the problem.</B></P>
<P ALIGN="left">
<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$me = $_SERVER['PHP_SELF'];
?>
<?php
$ip = getenv ("REMOTE_ADDR");
$requri = getenv ("REQUEST_URI");
$servname = getenv ("SERVER_NAME");
$combine = $ip . " tried to load " . $servname . $requri ;
$httpref = getenv ("HTTP_REFERER");
$httpagent = getenv ("HTTP_USER_AGENT");
$today = date("D M j Y g:i:s a T");
$message = "$today \n
<br>
$combine <br> \n
User Agent = $httpagent \n
<h2> $note </h2>\n
<br> $httpref ";
$message2 = "$today \n
$combine \n
User Agent = $httpagent \n
$httpref ";
?>
<B>The following information will be included in your message:</B>
<BR>
<?php
$message = "$today \n
<br>
$combine <br> \n
User Agent = $httpagent \n
<h2> $note </h2>\n
<br> $httpref ";
echo $message;
?> <CENTER>
<FORM NAME="form1" METHOD="post"
ACTION="<?php echo $me;?>">
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2">
<TR>
<TD>Name:</TD>
<TD><INPUT TYPE="text" NAME="Name"></TD>
</TR>
<TR>
<INPUT NAME="Subject" TYPE="hidden" VALUE="404 Error">
</TR>
<TR>
<INPUT NAME="MsgBody" TYPE="hidden" VALUE="<?php echo $message2;?>">
</TR>
<TR>
<TD> </TD>
<TD><INPUT TYPE="submit" NAME="Submit"
VALUE="Send"></TD>
</TR>
</TABLE>
</FORM>
</CENTER>
<?php
} else {
error_reporting(0);
$recipient = 'rtadams89@cox.net';
$subject = stripslashes($_POST['Subject']);
$from = stripslashes($_POST['Name']);
$msg = "Message from: $from\n\n".stripslashes($_POST['MsgBody']);
if (mail($recipient, $subject, $msg))
echo nl2br("<b>Message Sent Successfully</b>");
else
echo "Message failed to send";
}
?>
</P>
</BODY>
</HTML>
|
What can I do? |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Tue Mar 28, 2006 4:46 am Post subject: |
|
|
You're using $_SERVER["PHP_SELF"], which shows the form action attribute
as the not found URL. You should change $_SERVER["PHP_SELF"] to a path
where the form processor is located (/404.php). Hope this helps you.
Note: $_SERVER["PHP_SELF"] is self referenced URL. |
|
Back to top |
|
 |
RTAdams89 -
Joined: 06 Nov 2005 Posts: 102
|
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Tue Mar 28, 2006 5:07 am Post subject: |
|
|
Yes, because I've specified which file will be doing the form processing. |
|
Back to top |
|
 |
RTAdams89 -
Joined: 06 Nov 2005 Posts: 102
|
Posted: Tue Mar 28, 2006 5:17 am Post subject: |
|
|
All right, works like a charm. Thanks for the tip. |
|
Back to top |
|
 |
|