0

Hello Friends,

I have an issue after upgrading my firefox to version 4. This issue was there in IE8 but worked nicely in firefox3

Here is my issue:

I have a page with three forms and each form posts using "htmlentities($_SERVER)" action that is to the same page. Based on the posted value This page redirects to different pages.

This is not working any more and the same page is displayed.

What could be the reason?..

4
Contributors
11
Replies
13
Views
6 Years
Discussion Span
Last Post by an00p
Featured Replies
  • I have fixed this issue.. In my form, I am using image instead of button to submit the form: [CODE]echo "<form name=formuser action=# method=post>" echo "<input type=hidden value=".$rows['user_id']." name=user_id />"; echo "<input type=image src=images/more.png value=users_view name=users_view title=View />"; echo "</form>";[/CODE] and the PHP code at the beginning checks if "users_view" … Read More

0

Here is my code:

<?
session_start();
include 'includes/auth.php';
include 'includes/config.php';
$_SESSION['page']="users_list";
if ($_POST)
{
	if (isset($_POST['users_view']))
	{
		$_SESSION['id_view'] = $_POST['user_view'];
		header( 'Location: users_view.php' );
		exit;
	}
	elseif (isset($_POST['users_delete']))
	{
		$_SESSION['user_id'] = $_POST['user_delete'];
		header( 'Location: delete_confirm.php' );
		exit;
	}
}

$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
</head>
<body>
........
........
</body>
</html>
0

$_SERVER will surely just end up on the current page, so why not just use # and use hidden fields to transfer any data you need?

0

I need to POST data to the same page as the code below will redirect to different pages based on the POST values.

if ($_POST)
{
if (isset($_POST['users_view']))
{
$_SESSION['id_view'] = $_POST['user_view'];
header( 'Location: users_view.php' );
exit;
}
elseif (isset($_POST['users_delete']))
{
$_SESSION['user_id'] = $_POST['user_delete'];
header( 'Location: delete_confirm.php' );
exit;
}
}

The page "users_view.php" works on the value $_SESSION and delete_confirm.php uses the value $_SESSION.

It was working perfect until I upgrade firefox from version 3 to 4.

0

Yes, I understand you're going to the current page. My question was why you're choosing to use a global php variable to do so when you can just use "#"

0

I wasn't aware of it. Thank you for letting me know the use of "#"

But here the issue is not with posting to the same page. The issue is it doesn't redirect to other pages.

The POST check including page redirection is done before generating html codes. That is before <html></html>.

Update: Its working fine in "Google Chrome".

0

I may be wrong, but I think you have to set the session up after the header commands if they are to work.

0

IMO: sending a form to its own page is not a good idea. You should send it to a form handler, otherwise, reload/refresh causes problems.

0

That's correct. But in my case the page redirects to another one(eg: user_view.php) with the form data after the form is submitted to it. The page checks for the form data ("if ($_POST)")before the html is generated (ie. before <html></html>).
If the form is not submitted, the page acts just like a normal page and reload/refresh won't have any effect on the page.

0

If this method no longer works, or only in certain browsers, then instead of redirecting, you could use code like this:

<?
session_start();
include 'includes/auth.php';
include 'includes/config.php';
$_SESSION['page']="users_list";
if ($_POST)
{
	if (isset($_POST['users_view']))
	{
		$_SESSION['id_view'] = $_POST['user_view'];
		include "./users_view.php";
	}
	elseif (isset($_POST['users_delete']))
	{
		$_SESSION['user_id'] = $_POST['user_delete'];
		include "./delete_confirm.php";
	}
	else 
	{
    $sql="SELECT * FROM $tbl_name";
    $result=mysql_query($sql);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Test</title>
    </head>
    <body>
    ........
    ........
    </body>
    </html>
  }
}
1

I have fixed this issue..

In my form, I am using image instead of button to submit the form:

echo "<form name=formuser action=# method=post>"
echo "<input type=hidden value=".$rows['user_id']." name=user_id />";
echo "<input type=image src=images/more.png value=users_view name=users_view title=View />";
echo "</form>";

and the PHP code at the beginning checks if "users_view" is set (i.e. the image )

if (isset($_POST['users_view']))

I changed this if condition to check if "user_id" is set (i.e. hidden field)

if (isset($_POST['users_id']))

After that everything is working fine as before.

Thank you all for the support :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.