F5 REFRESH PHP FORM PROBLEM
Moderator: General Moderators
F5 REFRESH PHP FORM PROBLEM
hello all, I have a standard html hyperlink window which opens up a simple php form in a popup window. I have sorted out all the logic, form pprocess, validation but, when initially loaded if the user F5-refreses the window, the php/html page does not write itself out properly, eg no bgcolor, no text, just sey the form with the last third of the ACTUAL html code...(not what the html code is supposed to generate)!
why does the page output breakdown in this way, when the servers php module isn't showing any errors ?
Thanks in advance for any advice, Tod.
why does the page output breakdown in this way, when the servers php module isn't showing any errors ?
Thanks in advance for any advice, Tod.
why will the following code be generated first time-every time, without any js/css/html/php errors...but upon refresh (the user shouldnt need or have to) the page isn't output properly ?
d11wtq | Please use
Code: Select all
<?php
$form="<b><font color=\"#282028\">Your name<br><input maxLength=\"65\" name=\"sender\" value=\"\" size=\"25\"><br>Your e-mail address<br><input maxLength=\"65\" name=\"email_1\" value=\"\" size=\"25\"><br>Thier name<br><input maxLength=\"65\" name=\"friend\" value=\"\" size=\"25\"><br>Thier e-mail address<br><input maxLength=\"65\" name=\"email_2\" value=\"\" size=\"25\"></font></b><br><input type=\"hidden\" name=\"required\" value=\"sender,email_1,friend,email_2\"><br><input type=\"hidden\" name=\"efields\" value=\"email_1,email_2\"><input type=\"hidden\" name=\"eUrl\" value=\"http://www.morris-roots.com/main.htm\"><input type=\"hidden\" name=\"_submit_check\" value=\"1\">" . "<p align=\"right\" style=\"padding-right: 10px;\"><input type=\"submit\" value=\"submit\" style=\"color: #000000; background: #FFFFFF; font-size: 13px;\">";
?>
<html>
<head>
<meta name="robots" Content="NOINDEX,NOFOLLOW">
<title>Morris Roots...Tell A Friend</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="styles.css" type="text/css">
<style type="text/css">
Form {
font-family: arial, helvetica, sans-serif;
font-size:11px;
color:#684840;
font-weight:normal;
background-color:#ffffff;}
textarea, input, select {
font-family: arial, helvetica, sans-serif;
font-size:12px;
color:#384858;
font-weight:normal;
background-color:#ffffff;}
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="397" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" height="40" valign="middle" bgcolor="#FFFFFF" style="padding-left: 0px; padding-top: 6px; padding-right: 0px;"><img src="image1.jpg" width="136" height="25" border="0" alt=""></td>
</tr>
<tr>
<td colspan="2" height="40" valign="bottom" bgcolor="#FFFFFF" style="padding-left: 8px; padding-top: 12px; padding-right: 10px; padding-bottom: 12px; text-align: justify;"><span style="color:#282028; font-size:12px; font-weight:bold;">To tell a friend about Morris Roots, please complete the following information. We will send your friend a link to our website.<br>All fields are required.</span></td>
</tr>
<tr>
<td align="left">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="444" valign="bottom" bgcolor="#FFFFFF"><img src="tellafriend.jpg" width="247" height="395" border="0" alt=""></td>
</tr>
</table>
</td>
<td width="70%" align="left" valign="top">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr>
<td valign="top" style="padding-top: 0px;"><form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"><br><?php echo $form; ?></form></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" height="40" align="left" valign="bottom" bgcolor="#384858" style="padding-left: 1px; padding-top: 16px; padding-right: 18px;"><font color="#FFFFFF" size="1" face="Verdana Arial">Your e-mail address has been requested so that when your friend receives our link, your friend is able to reply directly to you. © </font></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>Code: Select all
tags when posting PHP code. Also note, posting in BLOCK CAPITALS does not encourage us to read your thread any faster[/color]- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
This is completely pointless 
$form is a plain string (all on one longgggggggggggggggggggggggggggg line)... no PHP code as such.
Why have you chosen to do this in PHP?
Also, I think it could be time to read up on the use of the <div> tag
EDIT | And you don't appear to actually use $form anywhere in this script... you simply define it
EDIT AGAIN | I see it now ($form) .... halfway across to the right
$form is a plain string (all on one longgggggggggggggggggggggggggggg line)... no PHP code as such.
Why have you chosen to do this in PHP?
Also, I think it could be time to read up on the use of the <div> tag
EDIT | And you don't appear to actually use $form anywhere in this script... you simply define it
EDIT AGAIN | I see it now ($form) .... halfway across to the right
Last edited by Chris Corbyn on Tue Jun 28, 2005 7:20 am, edited 1 time in total.
sorry about posting rules thingy. apologies.
no way...it always breaks down. just after loading, the user doesnt need to hit F5, but if they choose to the page will be output, starting with just the form fields, no css, no bgcolor (page is white), no title (but the actual URL), and the html code below the fields.. ??
could it be the nested tabling, the servers version of php?
Snookered, Tod
no way...it always breaks down. just after loading, the user doesnt need to hit F5, but if they choose to the page will be output, starting with just the form fields, no css, no bgcolor (page is white), no title (but the actual URL), and the html code below the fields.. ??
could it be the nested tabling, the servers version of php?
Snookered, Tod
hello, i tried to simplify the page before posting it-the final version didnt erase the users input when submitted with errors and sent the email etc. but in trying to get to the root of the problem I stripped it back to just the necessities. the full page is as follows, with validation etc... Please note, it is a slightly different page, but has the same problem,
kind regards. Tod. (hope its not PIBKAC)
Code: Select all
<?php
$form="<b><font color=\"#282028\">Your name<br><input maxLength=\"65\" name=\"sender\" value=\"\" size=\"25\"><br>Your e-mail address<br><input maxLength=\"65\" name=\"email_1\" value=\"\" size=\"25\"><br>Thier name<br><input maxLength=\"65\" name=\"friend\" value=\"\" size=\"25\"><br>Thier e-mail address<br><input maxLength=\"65\" name=\"email_2\" value=\"\" size=\"25\"></font></b><br><input type=\"hidden\" name=\"required\" value=\"sender,email_1,friend,email_2\"><br><input type=\"hidden\" name=\"efields\" value=\"email_1,email_2\"><input type=\"hidden\" name=\"eUrl\" value=\"http://www.xyz.com/main.htm\"><input type=\"hidden\" name=\"_submit_check\" value=\"1\">" . "<p align=\"right\" style=\"padding-right: 10px;\"><input type=\"submit\" value=\"submit\" style=\"color: #000000; background: #FFFFFF; font-size: 13px;\">";
if (!isset($sender)) {
$sender; $email_1; $friend; $email_2; $empty_count; $invalid_count; $empty_msg; $invalid_msg;
}
else {
$sender = $_REQUEST['sender'] ;
$email_1 = $_REQUEST['email_1'] ;
$friend = $_REQUEST['friend'] ;
$email_2 = $_REQUEST['email_2'] ;
$required = $_REQUEST['required'] ;
$addresses = $_REQUEST['efields'] ;
$pageUrl = $_REQUEST['eUrl'] ;
$required_fields = explode(",", $required);
$empty_count = 0;
$full = array("sender" => "name", "email_1" => "e-mail address",
"friend" => "freinds name", "email_2" => "friends e-mail address");
foreach($required_fields as $fieldname) {
if ($_REQUEST[$fieldname] == "") {
$empty_field[$empty_count] = $fieldname;
$empty_count++;
}
}
$arlength = count($empty_field);
if ($arlength==1) {
$empty_msg = "<font color=\"#B22222\">" . $full[$empty_field[0]] . "</font>";
}
if ($arlength==2) {
$empty_msg = "<font color=\"#B22222\">" . $full[$empty_field[0]] ."</font> and <font color=\"#B22222\">" . $full[$empty_field[1]] . "</font>";
}
if ($arlength==3) {
$empty_msg = "<font color=\"#B22222\">" . $full[$empty_field[0]] ."</font>, <font color=\"#B22222\">" . $full[$empty_field[1]] . "</font> and <font color=\"#B22222\">" . $full[$empty_field[2]] . "</font>";
}
if ($arlength==4) {
$empty_msg = "<font color=\"#B22222\">" . $full[$empty_field[0]] ."</font>, <font color=\"#B22222\">" . $full[$empty_field[1]] ."</font>, <font color=\"#B22222\">" . $full[$empty_field[2]] . "</font> and <font color=\"#B22222\">" . $full[$empty_field[3]] . "</font>";
}
if ($empty_count==0) {
$empty_msg = " ";
}
else {
$empty_msg = "Your " . $empty_msg . " cannot be incomplete. All fields are required. </font>";
}
$addresses = explode(",", $efields);
$invalid_count = 0;
foreach($addresses as $address_field) {
if (($_REQUEST[$address_field] == "") == FALSE) {
if ((strstr($_REQUEST[$address_field], "@") ==FALSE) and (strstr($_REQUEST[$address_field], ".")== FALSE)) {
$invalid_emails[$invalid_count] = $address_field;
$invalid_count++;
}
}
}
$invalid = count($invalid_emails);
if ($invalid==1) {
$invalid_msg = "<font color=\"#B22222\">" . $full[$invalid_emails[0]] ."</font> is";
}
if ($invalid==2) {
$invalid_msg = "<font color=\"#B22222\">" . $full[$invalid_emails[0]] ."</font> and <font color=\"#B22222\">" . $full[$invalid_emails[1]] ."</font> are";
}
if ($invalid_count==0) {
$invalid_msg =" ";
}
else {
$bgcolor = "#FFFFFF"; $buttoncolor = "#FFFFFF";
$invalid_msg = "<font color=\"#B22222\">Your " . $invalid_msg . " invalid.</font>";
}
if (($empty_count==0) and ($invalid_count==0)) {
$mail = TRUE;
}
}
?>
<html>
<head>
<meta name="robots" Content="NOINDEX,NOFOLLOW">
<title>xyz...Tell A Friend</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="styles.css" type="text/css">
<script type="text/javascript">
<!--
function checkkey() {
if (event.keyCode == 116) onunload = function() {};
if (event.keyCode == 82 && event.ctrlKey) onunload = function() {};
};
-->
</script>
</head>
<body bgcolor="#F1F1F3" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="document.theForm.sender.focus();" onkeydown="checkkey();">
<table width="530" border="0" cellspacing="0" cellpadding="1" align="center">
<tr>
<td bgcolor="#000000">
<table width="100%" bgcolor="#000000" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="left" width="268">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FFFFFF"><img src="http://www.hhxyz.com/image1.jpg" width="267" height="393" border="0"></td>
</tr>
</table>
</td>
<td width="70%" align="center" valign="top">
<table border="0" cellspacing="0" cellpadding="12" width="100%">
<tr>
<td colspan="2" align="left" valign="top" width="70%">
<table border="0" cellspacing="2" cellpadding="0" width="100%" style="padding-top: 15px;">
<tr>
<td valign="top"><font color="#FFFFFF" size="4"><b>Tell A Friend</b></font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="465" valign="top" style="height: 81px;"><font size="2" color="#FFFFFF"><?php
if (!isset($sender)) {
echo "<font color=\"#FFFFFF\">Please complete the following information and we will send your friend a link to our website. All fields are required.</font>";
}
else {
if (($empty_count==0) and ($invalid_count==0)) {
$today = date("F j, Y, g:i a");
$subject = $friend . ", Take a look at this natural hair website..";
$ip = $HTTP_SERVER_VARS["REMOTE_ADDR"];
$body="<center><font face=\"arial\" size=\"3\"><b>" . "<font color=\"#AA4E3C\">Hi " . $friend . "</font></b><br><br><br>" . "<font size=\"2\">Take a look at this natural hair website I saw while surfing !</font><br><br><a href=\"http://www.hhxyz.com/index.htm\" alt=\"Description of the website\"><b>http://www.hhxyz.com/index.htm</b></a></p><p><font size=\"2\">Speak to you soon,</font> <b><font color=\"#AA4E3C\">" . $sender . "</font></b><br>" . $email_1 . "</center><br><br><br><br><br><br><br><font size=\"2\"><b>-------------------------------------------------------------------------------------<br><font color=\"#9D3336\">hhxyz.Com</font></b>, <font color=\"#7B328F\">Locktician and Natural Hair Specialist</font><br><p>This email-a-friend service is brought to you by hhxyz.<br>We have included the following details for your personal online security: Email sent at <b>" . $today . "</b> at the request of the above visitor to our website using IP address <b>" . $ip ."</b>";
mail("$email_2", "$subject", "$body", "From: $sender <$email_1>\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1");
echo "We have sent your friend a link to our website. Click <a href=javascript:window.close(); title='close'><b>here</b></a> to return to the mainpage.</font>";
unset($sender); unset($email_1); unset($friend); unset($email_2);
}
else {
echo "<font size=\"2\" color=\"#FFFFFF\">The following errors were detected - " . $empty_msg ." " . $invalid_msg . "</font>";
}
} ?></b></font></td>
</tr>
<tr>
<td valign="top" style="padding-top: 0px;"><form method="POST" action="tellafriend.php"><?php echo $form; ?></form></td>
</tr>
<tr>
<td colspan="4" align="left" style="padding-top: 20px; width: 400px;"><font size="1" color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif"><b>Note:</b> Your e-mail address has been requested so that when your friend receives our link, your friend can reply directly to you, and not to us.</font></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>I've loaded and tested both versions you posted, and have no problem loading the complete page for both, whether on initial load, or on refresh.tod wrote:hello, i tried to simplify the page before posting it-the final version didnt erase the users input when submitted with errors and sent the email etc. but in trying to get to the root of the problem I stripped it back to just the necessities. the full page is as follows, with validation etc... Please note, it is a slightly different page, but has the same problem,
kind regards. Tod. (hope its not PIBKAC)
Which browser are you seeing this behavior in? I'm using FFox 1.04.
hello, i use IE5.5 on win98se, and just now to make sure I ftp re-uploaded it again, called a fresh browser window to display it (worked fine), mouseclicked the Refresh button, and waalaa...it didnt generate the output prpperly, the following was on a blank page
also, the page title had the url eg, http://www.xysssg.com/pagename.php, instead of the stuff between the <title> </title> tags.
Code: Select all
"e; size="e;25"e;>
Your e-mail address
field box here
Thier name
field box here
Thier e-mail address
field box here
Note: Your e-mail address has been requested so that when your friend receives our link, your friend can reply directly to you, and not to us.also, the page title had the url eg, http://www.xysssg.com/pagename.php, instead of the stuff between the <title> </title> tags.
if you dont believe me..go here (http://www.toks.me.uk/tellafriend.php)
sorry if url links arent allowed on postings.
kind regards.
sorry if url links arent allowed on postings.
kind regards.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
It works... what speed internet connection are you on (not that it should affect anything with a page this size).tod wrote:if you dont believe me..go here (http://www.toks.me.uk/tellafriend.php)
sorry if url links arent allowed on postings.
kind regards.
Sounds like it could be your browser ... I just tested on Windows NT4 and 2000 both running IE 5.5 at work.
totally baffled..
i have a 56k connection, probably v90 modem. been trying to fix it for a day.
should i start believin in gremlins?
baffled...tod.
should i start believin in gremlins?
baffled...tod.
Re: totally baffled..
There are ways you can improve the experience for users (like yourself) that may lose your connection mid-stream:tod wrote:i have a 56k connection, probably v90 modem. been trying to fix it for a day.
should i start believin in gremlins?
baffled...tod.
- Use HTML valid code. That way the browser doesn't have to redraw multiple times when it gets new data.
- Use output buffering. By buffering the output, you send it all in one quick burst, instead of streaming it as it is assembled.
- Use CSS and HTML. By seperating the styling/presentation out, that can be cached, which reduces the overall transmission time
- Use gzip compression. Again, less sent means less time the connection can die during.