By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 889 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

help pls!

P: 2
hi! im olive, i only new the basics of php and i have this problem..our website has it's own feedback form but for some reasons it's not working, can someone help me find what could be the problem in the script coz everytime i hit the submit form in the feedback form page it always return the error 'Invalid Entry: Hit your browsers back button and resubmit the form.' and the message posted is not saved at all..here are the scripts used in our feedback form and the html form. please someone who could help me..thank you.

loginf.php

<?php
//Change these to match your site.

$bgcolor = '#FFFFFF';
$title = 'PVAO Feedback';
$font = 'Arial';
$fontcolor = '#666633';
$tfont = '"#666633';
$guestinfo_tablecolor = '#CCFFCC';
$messagebody_tablecolor = '#CCFFCC';
$guestinfo_fontcolor = '#666633';
$messagebody_fontcolor = '#666633';
$data = 'guestbook.dat';
$posted_on = Date("M d, Y");
$ok_to_post = 1;
$error_string = 'Invalid Entry: Hit your browsers back button and resubmit the form.';
?>


-----
log.php

<?php


require ("loginf.php");
echo "<html>";
echo "<head>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"pvao.css\">";
echo "<title>$title</title>";
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"5; URL=feedbac.html\">";
echo "</head>";
echo "<body bgcolor=\"$bgcolor\">";
if(!$guest){
echo "$error_string";
$ok_to_post = 0;
exit;
}

echo "<h4>Thank you for your feedback<br>You will be redirected to the Feedback Page in a moment.<br><br><a href=\"http://server.pvao.mil.ph/feedbac.html\">Click here</a> if you don't want to wait.</h4>";
$entered = FALSE;
if (file_exists($data))
{
$guestentry = "$guest|$email|$url|$message|$R1|$R2|$posted_on\n" ;
$file = fopen($data,"a");
if(flock($file,2))
fputs($file,$guestentry);
else
exit("Error: couldn't open file");
if(flock($file,3))
fclose($file);
else
exit("Error: couldn't open file");
$entered = TRUE;
}
?>

------

logview.php

<?php
require ("loginf.php");
$home_url='http://server.pvao.mil.ph';
echo "<html>";
echo "<head>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"pvao.css\">";
echo "<title>$title</title>";
echo "<body bgcolor=\"$bgcolor\">";
echo "<center><h3>$title View </h3></center>";
echo "<a href=\"index.html\">Back to PVAO Main</a><br> <br>";


if (file_exists($data))
{
$afile = file($data);
for($num = 0; $num < count($afile); $num++)
{
$bfile = explode("|",$afile[$num]);
echo "<br><div align=\"center\">";
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" width=\"85%\">";
echo "<td width=\"10%\" bgcolor=\"$guestinfo_tablecolor\" align=\"right\" valign=\"top\">";
echo "<p align=\"right\">Last Signed: <br>";
echo "By<br>";
echo "E-Mail:<br>Address:<br>R1:<br>R2:</td>";
echo "<td width=\"50%\" bgcolor=\"$guestinfo_tablecolor\" valign=\"top\">";
echo "$bfile[6]<br>$bfile[0]<br>$bfile[1]<br>$bfile[2]<br>$bfile[4]<br>$bfile[5]</td></tr></table></div>";
echo "<div align=\"center\">";
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" width=\"85%\">";
echo "<tr>";
echo "<td width=\"10%\" bgcolor=\"$messagebody_tablecolor\" valign=\"top\" align=\"right\">Message:</td>";
echo "<td width=\"65%\" valign=\"top\" bgcolor=\"$messagebody_tablecolor\">$bfile[3]</td></tr></table></div>";
echo "<hr>";
}
}
else
{
echo "<tr><td>Couldn't open $data</td></tr>";
}
?>
<BR>
<BR>
<BR>
</body>
</html>

---
Jan 8 '08 #1
Share this Question
Share on Google+
1 Reply


rpnew
100+
P: 188
hi! im olive, i only new the basics of php and i have this problem..our website has it's own feedback form but for some reasons it's not working, can someone help me find what could be the problem in the script coz everytime i hit the submit form in the feedback form page it always return the error 'Invalid Entry: Hit your browsers back button and resubmit the form.' and the message posted is not saved at all..here are the scripts used in our feedback form and the html form. please someone who could help me..thank you.

loginf.php

<?php
//Change these to match your site.

$bgcolor = '#FFFFFF';
$title = 'PVAO Feedback';
$font = 'Arial';
$fontcolor = '#666633';
$tfont = '"#666633';
$guestinfo_tablecolor = '#CCFFCC';
$messagebody_tablecolor = '#CCFFCC';
$guestinfo_fontcolor = '#666633';
$messagebody_fontcolor = '#666633';
$data = 'guestbook.dat';
$posted_on = Date("M d, Y");
$ok_to_post = 1;
$error_string = 'Invalid Entry: Hit your browsers back button and resubmit the form.';
?>


-----
log.php

<?php


require ("loginf.php");
echo "<html>";
echo "<head>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"pvao.css\">";
echo "<title>$title</title>";
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"5; URL=feedbac.html\">";
echo "</head>";
echo "<body bgcolor=\"$bgcolor\">";
if(!$guest){
echo "$error_string";
$ok_to_post = 0;
exit;
}

echo "<h4>Thank you for your feedback<br>You will be redirected to the Feedback Page in a moment.<br><br><a href=\"http://server.pvao.mil.ph/feedbac.html\">Click here</a> if you don't want to wait.</h4>";
$entered = FALSE;
if (file_exists($data))
{
$guestentry = "$guest|$email|$url|$message|$R1|$R2|$posted_on\n" ;
$file = fopen($data,"a");
if(flock($file,2))
fputs($file,$guestentry);
else
exit("Error: couldn't open file");
if(flock($file,3))
fclose($file);
else
exit("Error: couldn't open file");
$entered = TRUE;
}
?>

------

logview.php

<?php
require ("loginf.php");
$home_url='http://server.pvao.mil.ph';
echo "<html>";
echo "<head>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"pvao.css\">";
echo "<title>$title</title>";
echo "<body bgcolor=\"$bgcolor\">";
echo "<center><h3>$title View </h3></center>";
echo "<a href=\"index.html\">Back to PVAO Main</a><br> <br>";


if (file_exists($data))
{
$afile = file($data);
for($num = 0; $num < count($afile); $num++)
{
$bfile = explode("|",$afile[$num]);
echo "<br><div align=\"center\">";
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" width=\"85%\">";
echo "<td width=\"10%\" bgcolor=\"$guestinfo_tablecolor\" align=\"right\" valign=\"top\">";
echo "<p align=\"right\">Last Signed: <br>";
echo "By<br>";
echo "E-Mail:<br>Address:<br>R1:<br>R2:</td>";
echo "<td width=\"50%\" bgcolor=\"$guestinfo_tablecolor\" valign=\"top\">";
echo "$bfile[6]<br>$bfile[0]<br>$bfile[1]<br>$bfile[2]<br>$bfile[4]<br>$bfile[5]</td></tr></table></div>";
echo "<div align=\"center\">";
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" width=\"85%\">";
echo "<tr>";
echo "<td width=\"10%\" bgcolor=\"$messagebody_tablecolor\" valign=\"top\" align=\"right\">Message:</td>";
echo "<td width=\"65%\" valign=\"top\" bgcolor=\"$messagebody_tablecolor\">$bfile[3]</td></tr></table></div>";
echo "<hr>";
}
}
else
{
echo "<tr><td>Couldn't open $data</td></tr>";
}
?>
<BR>
<BR>
<BR>
</body>
</html>

---
Hi,

Haven't checked your code throughly but it seems that here where it is throwing the error....

[PHP]
if(!$guest){
echo "$error_string";
$ok_to_post = 0;
exit;
}
[/PHP]

So check for the '$guest' value in your code. Or from wherever it is coming.

Regards,
RP
Jan 8 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.