Forum Moderators: coopster

Message Too Old, No Replies

refresh problem

refresh problem

         

xbl01234

10:05 am on Dec 20, 2006 (gmt 0)

10+ Year Member



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

[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>
[/php]


edit3.php

[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']);

?>

[/php]

tomda

10:32 am on Dec 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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.

This is a clear explanation to me.
It is not a PHP problem, just a new feature from IE7 I guess (don't know because not installed yet) that refrain users to go back in form.

Open another browser (firefox, opera), try again and see what happened.

PS2 - You may want to read few threads about SQL injection. From what I have seen, your script is vulnerable because you don't check passed variable. Hope it is understandable :)

mcibor

10:43 am on Dec 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Tomda, it's not a problem connected directly with browser.

This warning appears if the previous page was created with POST variables.
If it appears then simply hit refresh button, but this will send the POST once again. So if you don't want to post the data once again create a button with a link

<input type="button" onclick="window.location.href='edit2.php'">

Regards
Michal

xbl01234

12:37 pm on Dec 20, 2006 (gmt 0)

10+ Year Member



Michal;

After i added the code, i got masage like the following;

the code i add to end of the edit3.php;

......
......
unset($_SESSION['Cid']);
?>

<form>
<input type="button" onclick="window.location.href='http://www.businessfind101.com/edit2.php'">
</form>


Warning:
mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in /home/biznisfi/public_html/edit2.php on line 40

and the following code from the edit2.php start on the line 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>

mcibor

1:44 pm on Dec 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why do you want to go back to that page?

You would need to pass $_POST['Cid'] somehow.
by get method, or with session:

in edit2.php change

if(isset($_POST['Cid'])) $arrCid = $_POST['Cid'];
else $arrCid = $_SESSION['arrCid'];

if(is_array($arrCid)){
$_SESSION['arrCid'] = $arrCid;
foreach($arrCid as $value)
$result = mysql_query("select * from Customer2 where Cid='$value'");
}

This should solve the problem

Merry Xmas
Michal Cibor

xbl01234

7:48 am on Dec 21, 2006 (gmt 0)

10+ Year Member




Why do you want to go back to that page?
You would need to pass $_POST['Cid'] somehow.
by get method, or with session:

in edit2.php change

if(isset($_POST['Cid'])) $arrCid = $_POST['Cid'];
else $arrCid = $_SESSION['arrCid'];

if(is_array($arrCid)){
$_SESSION['arrCid'] = $arrCid;
foreach($arrCid as $value)
$result = mysql_query("select * from Customer2 where Cid='$value'");
}

This should solve the problem

Hi;
Michal;
thanks for your time and Merry Xmas to you. i tested passed the Post['Cid'] by get method, it work very well, there is not refresh problem for that.

but i am still working for pass Post['Cid'] by sending session varible, it still got the refresh problem, but better than before, at least, i click on the refresh button, it can go back to edit2.php, compare with it could not do that before.

Thanks again, i need to carry on to solve the problem.