我有一个奇怪的问题,我有一个脚本在网站的其他地方工作,但现在拒绝为我工作。问题是IE独有的,它在Mozilla中运行良好。 以下是表格:
<form class="element_form" action="general_image.php" method="post">
<?php generate_input('hidden', '', 'id', $id);?>
<input type="image" src="../images/delete.gif" name="action" value="delete" class="button" />
<input type="image" src="../images/tick.gif" name="action" value="active_switch" class="button" />
</form>
这是应该起作用的代码:
<?php
include('header.php');
$db->connect();
$table = 'general_image';
$page = 'general';
$region = $_SESSION['region'];
$action = $secure->secure_string($_REQUEST['action']);
$id = $secure->secure_string($_POST['id']);
$max_active = 1;
if($action == 'active_switch' || $action == 'delete'){
$response = array();
$response['action'] = $action;
$response['id'] = $id;
if($action == 'active_switch'){
$query = 'SELECT * FROM general WHERE region = "' . $region . '"';
$result = mysql_query($query);
if(!$result) {
$utility->fail($action, 'query error: ' . $query);
}else{
$row = mysql_fetch_assoc($result);
$already_active = false;
$active = '';
if($id == $row['fifi']){
$already_active = true;
}
$active .= $row['fifi'];
$response['results'] = $active;
if(!$already_active){
$update = '';
$active = '';
$update .= 'fifi="' . $id . '"';
$active .= $id;
$query = 'UPDATE general SET ' . $update . ' WHERE region = "' . $region . '"';
$response['results'] = $active;
}else{
$utility->redirect($page . '.php');
}
}
}elseif($action == 'delete') {
$query = "DELETE FROM $table WHERE id=" . $id;
}
echo $query . "hello";
if(!mysql_query($query)) {
$utility->fail($action, 'query error: ' . $query);
}
如果有人能告诉我我做错了什么就会很棒。感谢
修改
$action = $secure->secure_string does the following:
function secure_string($string)
{
return (strip_tags(addslashes(mysql_real_escape_string(stripslashes($string)))));
}
答案 0 :(得分:1)
我发现有时最好有一个隐藏的字段用于操作然后提交按钮或图像。如果有人按RETURN或ENTER提交表格将返回哪个动作?
答案 1 :(得分:1)
例如,按钮图片包含:name="submitP"
和value="Print"
在FORM post PHP中,我使用了:
if(isset($_REQUEST['submitP']) || isset($_REQUEST['submitP_x']))
{ something....
}
如果第二个条款是对待后IE
答案 2 :(得分:0)
你还记得session_start();
吗?
答案 3 :(得分:-1)
我认为输入[type ='image']在IE中被破坏了。尝试使用按钮[type ='submit']代替。