Jump to content

refresh problem


xbl1

Recommended Posts

Hello; :):) i got a refresh problem. i got two php page at the movement, which they called edit2.php and edit3.php. when i submit a form from edit2.php to edit3.php, then i could not come back from edit3.php to edit2.php.Could you tell why, please. The following is warning masage;Warning: Page has Expired The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you. To resubmit your information and view this Web page, click the Refresh button. edit2.php

<?session_start();?><html><head> <STYLE> .TA {scrollbar-3dlight-color:palegreen;   scrollbar-arrow-color:yellow;   scrollbar-base-color:blue;   scrollbar-darkshadow-color:orange;   scrollbar-face-color:aqua;   scrollbar-highlight-color:blue;   scrollbar-shadow-color:teal} </STYLE></head><body> <? $con = mysql_connect("localhost", "#*$!x","#*$!xx"); if (! $con) {  die('Could not connect: ' . mysql_error()); }mysql_select_db("#*$!#*$!", $con);  $arrCid=$_POST['Cid'];  if(is_array($arrCid)){   foreach($arrCid as $value)   $result = mysql_query("select * from Customer2 where Cid='$value'");   } ?><form action='edit3.php' method="POST"><?while($row = mysql_fetch_array($result)){  $_SESSION['Cid']=$row['Cid'];?><input type="text" name="topic[]" maxlength=30 value="<? echo $row['Topic'];?>"><br>   <TEXTAREA name="des[]" wrap=on cols="50" class="TA" rows="10" onkeyup="this.value = this.value.slice(0, 200)"> <? echo $row['Des'];?> </TEXTAREA> <input type="submit" value="Submit"></form><?}?></body></html>

edit3.php

<?session_start();?><?  $con = mysql_connect("localhost", "#*$!#*$!","#*$!#*$!"); if (! $con) {  die('Could not connect: ' . mysql_error());  }  mysql_select_db("#*$!#*$!", $con);  if(isset($_SESSION['Cid']))  $cid=$_SESSION['Cid'];   $arrtopic = $_REQUEST['topic'];  if(is_array($arrtopic)){  foreach($arrtopic as $value)   $sql = "update Customer2 set Topic='$value' where Cid= '$cid'";   mysql_query($sql);   } $arrdes=$_POST['des'];  if(is_array($arrdes)){  foreach($arrdes as $value)   $sql = "update Customer2 set Des='$value' where Cid='$cid'";   mysql_query($sql);   } unset($_SESSION['Cid']);?>

Link to comment
Share on other sites

if you just want to get back from edit3 after a submit u chould have this after your last query :echo"<meta http-equiv='Refresh' content='1; URL=edit2.php'>";=)
i added to the edit3 as following; unset($_SESSION['Cid']); echo"<meta http-equiv='Refresh' content='1; URL=edit2.php'>";but it give me some error masage after i add the code.Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/biznisfi/public_html/edit2.php on line 40and the following code from edit2.php which it stat from the line of 40;<form action='edit3.php' method="POST">
<?while($row = mysql_fetch_array($result)){	  $_SESSION['Cid']=$row['Cid'];?><input type="text" name="topic[]" maxlength=30 value="<? echo $row['Topic']; ?>"><br>	   <TEXTAREA name="des[]" wrap=on cols="50" class="TA" rows="10" onkeyup="this.value = this.value.slice(0, 200)"> <? echo $row['Des']; ?> </TEXTAREA> <input type="submit" value="Submit"></form>

:)

Link to comment
Share on other sites

i added to the edit3 as following; unset($_SESSION['Cid']); echo"<meta http-equiv='Refresh' content='1; URL=edit2.php'>";but it give me some error masage after i add the code.Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/biznisfi/public_html/edit2.php on line 40and the following code from edit2.php which it stat from the line of 40;<form action='edit3.php' method="POST">
<?while($row = mysql_fetch_array($result)){	  $_SESSION['Cid']=$row['Cid'];?><input type="text" name="topic[]" maxlength=30 value="<? echo $row['Topic']; ?>"><br>	   <TEXTAREA name="des[]" wrap=on cols="50" class="TA" rows="10" onkeyup="this.value = this.value.slice(0, 200)"> <? echo $row['Des']; ?> </TEXTAREA> <input type="submit" value="Submit"></form>

:)

Hmm, try add it like this at the end :<? echo"<meta http-equiv='Refresh' content='1; URL=edit2.php'>";?>should work :) hehe...
Link to comment
Share on other sites

Hmm, try add it like this at the end :<? echo"<meta http-equiv='Refresh' content='1; URL=edit2.php'>";?>should work :blink: hehe...
>Hmm, try add it like this at the end :><?>echo"<meta http-equiv='Refresh' content='1; URL=edit2.php'>";>?>Thanks a lot, it work now. :blink::):):):blink:
Link to comment
Share on other sites

anytime =)
Hello Kristian_C;Sorry to bother again;Last night the code work very well, there was not refresh problem since i added a code as you said. but this morning, the refresh problem come back again, i didn't change my code. Please help :) i give you all the code i got;edit.php
<html><body><form action='edit2.php' method="POST"><? $con = mysql_connect("localhost", "xxx","xxxx");  if (! $con)  {  die('Could not connect: ' . mysql_error());  } mysql_select_db("xxxx", $con); $result = mysql_query("select * from Customer2 where UserName='$_POST[userName]'");while($row = mysql_fetch_array($result)){	  ?><input type="radio" name="Cid[]" value="<? echo $row['Cid']; ?>"><? echo $row['Des'];?><br><?}?><input type="submit" value="submit"><input type="reset" value="reset"></form></body></html>

edit2.php

<?php session_start(); ?><html><head><STYLE>.TA {scrollbar-3dlight-color:palegreen;scrollbar-arrow-color:yellow;scrollbar-base-color:blue;scrollbar-darkshadow-color:orange;scrollbar-face-color:aqua;scrollbar-highlight-color:blue;scrollbar-shadow-color:teal}</STYLE></head><body><? $con = mysql_connect("localhost", "xxxx","xxxxxxxx");if (! $con){die('Could not connect: ' . mysql_error());}mysql_select_db("xxxxxxx", $con);$arrCid=$_POST['Cid'];if(is_array($arrCid)){foreach($arrCid as $value)$result = mysql_query("select * from Customer2 where Cid='$value'"); } ?><form action='edit3.php' method="POST"><?while($row = mysql_fetch_array($result)){$_SESSION['Cid']=$row['Cid'];?><input type="text" name="topic[]" maxlength=30 value="<? echo $row['Topic'];?>"><br><TEXTAREA name="des[]" wrap=on cols="50" class="TA" rows="10" onkeyup="this.value = this.value.slice(0, 200)"> <? echo $row['Des'];?> </TEXTAREA> <input type="submit" value="Submit"></form><?}?></body></html>

edit3.php

<?session_start();?><? $con = mysql_connect("localhost", "xxxx","xxxx");if (! $con){die('Could not connect: ' . mysql_error());}mysql_select_db("xxxx", $con);if(isset($_SESSION['Cid']))$cid=$_SESSION['Cid'];$arrtopic = $_REQUEST['topic'];if(is_array($arrtopic)){foreach($arrtopic as $value) $sql = "update Customer2 set Topic='$value' where Cid= '$cid'";mysql_query($sql);}$arrdes=$_POST['des'];if(is_array($arrdes)){foreach($arrdes as $value)$sql = "update Customer2 set Des='$value' where Cid='$cid'";mysql_query($sql);}unset($_SESSION['Cid']);?><?echo"<meta http-equiv='Refresh' content='1; URL='http://www.businessfind101.com/edit2.php'>";?>

Link to comment
Share on other sites

Huh.. try this one :<?header( 'refresh: 0; url=http://www.businessfind101.com/edit2.php' );?>that one must work :)
it may be my coding problem. after i added the header, it give me the masage like that;Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/biznisfi/public_html/edit2.php on line 36this code from edit2 and start on the line 36
<form action='edit3.php' method="POST"><?while($row = mysql_fetch_array($result)){$_SESSION['Cid']=$row['Cid'];?><input type="text" name="topic[]" maxlength=30 value="<? echo $row['Topic'];?>"><br><TEXTAREA name="des[]" wrap=on cols="50" class="TA" rows="10" onkeyup="this.value = this.value.slice(0, 200)"> <? echo $row['Des'];?> </TEXTAREA> <input type="submit" value="Submit"></form>

Link to comment
Share on other sites

Well if you have every thing in the DB i dont see anything wrong...my final solution may be this:make a new file :just add the refresh in it... and add :<?include "refresh.php";?>at the end of edit3...if that wont work its your code that are missing something.. so just check everything in your db to see if it matches your code.. if it does add the file and test... - Kris

Link to comment
Share on other sites

Well if you have every thing in the DB i dont see anything wrong...my final solution may be this:make a new file :just add the refresh in it... and add :<?include "refresh.php";?>at the end of edit3...if that wont work its your code that are missing something.. so just check everything in your db to see if it matches your code.. if it does add the file and test... - Kris
Thanks a lot, i will going test it.
Link to comment
Share on other sites

No, including it wont do anything. Try to fix the error that php displays, the parser is always right. It appears that the mysql_fetch_array() has an empty result or something of that sort. Where it says "while($row = mysql_fetch_array($result)){" use this code:

$row_result = mysql_fetch_array($result) or die(mysql_error());while($row = $row_result){

then tell us what error comes up. It may be that your table in mysql is empty so $result is returning 0, or false. That could be the whole problem..

Link to comment
Share on other sites

The error is because the query is not being executed, because there is no post data.You need to think about what you are doing here, and what you want to do. You have edit.php, which submits a form to edit2.php. edit2.php processes the form information that was sent from edit.php, and displays another form that submits to edit3.php. edit3.php processes the form from edit2.php, and then redirects back to edit2. edit2.php comes up with an error because it's trying to process form data that isn't there (since it processes the form data from edit.php, and now you're just redirecting from edit3.php instead of submitting a form for it to process). This is why the error happens:

$arrCid=$_POST['Cid'];if(is_array($arrCid)){foreach($arrCid as $value)$result = mysql_query("select * from Customer2 where Cid='$value'"); } ?><form action='edit3.php' method="POST"><?while($row = mysql_fetch_array($result)){$_SESSION['Cid']=$row['Cid'];?>

The mysql_fetch_array call that raises the error says that $result is not a valid resource. If you look up to where you create $result, it is inside an if statement that checks if a value in the post data is an array. Since there is no post data because you redirected instead of submitting the form, the if statement will fail, $result will not get created, and the call to mysql_fetch_array will fail.There are several ways to fix this problem, but you need to figure out what you're trying to do with these pages. Since edit2.php is a form processor only by how it is written, it doesn't make sense to redirect there. You would need to either redirect somewhere else, or change edit2.php so that it can still handle a case where there is no post data.Also, to do a redirect, use this:<?phpheader("Location: edit2.php");?>

Link to comment
Share on other sites

No, including it wont do anything. Try to fix the error that php displays, the parser is always right. It appears that the mysql_fetch_array() has an empty result or something of that sort. Where it says "while($row = mysql_fetch_array($result)){" use this code:
$row_result = mysql_fetch_array($result) or die(mysql_error());while($row = $row_result){

then tell us what error comes up. It may be that your table in mysql is empty so $result is returning 0, or false. That could be the whole problem..

Hi reportingsjr;After i added the test code on, the parser does not say anything, but it bring a lot of submit form from edit2.php, and never stop, but i can go to the edit3.php page, and also the refresh problem still there.
<form action='edit3.php' method="POST"><?$row_result = mysql_fetch_array($result) or die(mysql_error());while($row = $row_result){$_SESSION['Cid']=$row['Cid'];?><input type="text" name="topic[]" maxlength=30 value="<? echo $row['Topic'];?>"><br><TEXTAREA name="des[]" wrap=on cols="50" class="TA" rows="10" onkeyup="this.value = this.value.slice(0, 200)"> <? echo $row['Des'];?> </TEXTAREA> <input type="submit" value="Submit"></form>

Link to comment
Share on other sites

The error is because the query is not being executed, because there is no post data.You need to think about what you are doing here, and what you want to do. You have edit.php, which submits a form to edit2.php. edit2.php processes the form information that was sent from edit.php, and displays another form that submits to edit3.php. edit3.php processes the form from edit2.php, and then redirects back to edit2. edit2.php comes up with an error because it's trying to process form data that isn't there (since it processes the form data from edit.php, and now you're just redirecting from edit3.php instead of submitting a form for it to process). This is why the error happens:
$arrCid=$_POST['Cid'];if(is_array($arrCid)){foreach($arrCid as $value)$result = mysql_query("select * from Customer2 where Cid='$value'"); } ?><form action='edit3.php' method="POST"><?while($row = mysql_fetch_array($result)){$_SESSION['Cid']=$row['Cid'];?>

The mysql_fetch_array call that raises the error says that $result is not a valid resource. If you look up to where you create $result, it is inside an if statement that checks if a value in the post data is an array. Since there is no post data because you redirected instead of submitting the form, the if statement will fail, $result will not get created, and the call to mysql_fetch_array will fail.There are several ways to fix this problem, but you need to figure out what you're trying to do with these pages. Since edit2.php is a form processor only by how it is written, it doesn't make sense to redirect there. You would need to either redirect somewhere else, or change edit2.php so that it can still handle a case where there is no post data.Also, to do a redirect, use this:<?phpheader("Location: edit2.php");?>

Hi justsomeguy;You are right, there is not value in the edit2.php after i redict back to edit2.php from edit3.php. Becaue the value get from edit.php, but now i don't excute the edit.php to let it pass value to edit2.php. This is why i has the refresh problem. Thanks a lot, you give me a very good analysis, i understand it now.What i am doing for the code? I want to let the user update their data by themself, and save it back to database. and i do that by the following step as what you said from last thread.1) ask the user name by a formbut here, i will pass the user cid to eddit2.php by attached the cid value to a textbox as well, for later use.2) base on the user name, i will select the user data out of database, then diplay on a screen to let the user edit their detail, after finish that, i will save the update data to database.and also i will receied the cid value which it is from edit.ph, and put it into the session varible for edit3.php use.3) in the edit3.php, according the cid value which from edit.pho, and processing it from edit2.php, i will update the user's data. then redirect back to previous page.The above is all i want to do.But you are right, that doesn't make sence to redirect back to edit2.php, because it is just a submit form, nothing else.so i will redirect to another page.but after i added the redirect code on, it give me some massage as following;Warning: Cannot modify header information - headers already sent by (output started at /home/biznisfi/public_html/edit3.php:6) in /home/biznisfi/public_html/edit3.php on line 43the code i added as following; this is edit3.php
<?session_start();?><? $con = mysql_connect("localhost", "biznisfi_xbl","1968rich");if (! $con){die('Could not connect: ' . mysql_error());} mysql_select_db("biznisfi_xbl", $con);if(isset($_SESSION['Cid']))$cid=$_SESSION['Cid'];$arrtopic = $_REQUEST['topic'];if(is_array($arrtopic)){foreach($arrtopic as $value) $sql = "update Customer2 set Topic='$value' where Cid= '$cid'";mysql_query($sql);}$arrdes=$_POST['des'];if(is_array($arrdes)){foreach($arrdes as $value)$sql = "update Customer2 set Des='$value' where Cid='$cid'";mysql_query($sql);}unset($_SESSION['Cid']);?><?phpheader("Location: index.php");?>

even i change the redirtect to www.ebay.com, it does not help. Could you tell what's problem here, Thanksand the index.php like the following, it just use to link to the edit.php, etc, nothing else, not value problem in here.

<html><head><style type="text/css"></style></head><body>	<center>   <a href='tologin.php'>login</a>   <a href='index.php'> Search </a>   <a href='submit.php'>submit your words</a>   <a href='eUserName.php'>Delete your words</a>   <a href='eUserE.php'> Edit your words </a>   <a href='oTopic.php'> OverView Topic </a>   </center>   <center>	 <form name="input" class="id1" action="st1.php" method="get">	 Search:	  <input type="text" name="SText">	  <input type="submit" value="Submit">	  </form>	</center></body></html>

:):):)

Link to comment
Share on other sites

I am almost there now, haha. :):):) i added the redirect code to the end of edit3.php as following, they work.

<?echo"<meta http-equiv='Refresh' content='1; URL=index.php'>";?>

or

<?phpecho "<meta http-equiv=\"refresh\" content=\"1;URL=http://www.businessfind101.com/\">";?>

But the problem for me, it work in funny way.after i edit the form from edit2.php, and then it gos to the edit3.php, the funny thing is here, it automatically go back to the index.php by itself. that is not good way to back, i need it back to index.php when i press the back from the top button of bar.and also i find another strange thing as well. After i redirect back to index.php from the edit3.php by automatically (althoght i don't like it), i will find another refersh problem as well when i click on the back from the index.php.and the masage as following;Warning: Page has Expired The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you. To resubmit your information and view this Web page, click the Refresh button. and the top of the address bar has : http://www.businessfind101.com/edit2.phpCould you tell me how solve these problem?

Link to comment
Share on other sites

Hi justsomeguy, reportingsjr;I had solve the refresh problem already. :):):) i am using Post method to pass the cid value from edit2.php to edit3.php without using session varible, and make the text filed invisible and readonly.<input type="text" style="visibility:hidden;" name="cid[]" size=1 value=" <? echo $row['Cid'] ?>" readonly="readonly"> But why i do like that, there is the refresh problem any more. Could you annalysis the reason to me?And also if you are free, could you help me to solve the refresh problem by useing the session varible to pass the cid value, i am keen to know how to do that. Thanks.

Link to comment
Share on other sites

  • 2 weeks later...

About the warning that the headers could not be modified because output was already started, it is because you are sending some whitespace to the browser. Any time you send anything to the browser for the first time, PHP will send all the headers at that time. Since the redirect is a header, you can only use the header function if output has not been send yet. The warning message indicates that line 6 was where the output started, which is just this:

<?session_start();?><?$con = mysql_connect("localhost", "biznisfi_xbl","");

The thing that gets sent to the browser is the linebreak on the blank line. You can just remove the PHP tags and that will not get sent and fix the error:

<?session_start();$con = mysql_connect("localhost", "biznisfi_xbl","");

There's another one near the end, before the header function:

unset($_SESSION['Cid']);?><?phpheader("Location: index.php");?>

unset($_SESSION['Cid']);header("Location: index.php");?>

If you want to have the CID in the session, then remove that unset function call. That deletes the CID from the session. If you leave it in the session, then you can access it on any other page.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...