一个表单,如何实现点击提交后,自动刷新一下页面?在我点击“生成“后,页面自动刷新一下<style type="text/css">
td {border:solid 1px #ADCEF3; background:#F0F5FD}
</style> 
<?php 
    $file=fopen("update2.xml","r");  //打开文件 
    $fp=fread($file,filesize("update2.xml")); //读取文件$i=0;                  //判断网页是不是第一次打开
    $fp1=fopen("1.txt","r"); //打开存post的 文件  要是没有这个文件 则新建  一行为一个post的值 加入post的值为空则为空行
    $array=file("1.txt");  //读取文件  一个单元为一行
    $str="";            
?> 
 
   <form method="post" name="name1">
   
   <table width="750" cellspacing="8">
  <tr>
    <td><div align="right">atestupdate[version]:
      </th>
    </div>
    <td><input type="text" name="a_version"  value="<?php if(isset($array[0]) and $i==0) echo $array[0]; //假如网页时第一次打开则 显示上次修改的值 ?>"></th>  </tr>
  <tr>
    <td><div align="right">atestupdate[url]:</div></td>
    <td><input type="text" name="a_url"  value="<?php if(isset($array[1]) and $i==0) echo $array[1]; //假如网页时第一次打开则 显示上次修改的值 ?>"></td>
  </tr>
  <tr>
    <td><div align="right">setup [version]:</div></td>
    <td><input type="text" name="s_version" value="<?php if(isset($array[2]) and $i==0) echo $array[2]; //假如网页时第一次打开则 显示上次修改的值 ?>"></td>
  </tr>
  <tr>
    <td><div align="right">setup [url]:</div></td>
    <td><input type="text" name="s_setup" value="<?php if(isset($array[3]) and $i==0) echo $array[3]; //假如网页时第一次打开则 显示上次修改的值 ?>"></td>
  </tr>
  <tr>
    <td><div align="right">leftlistversion version:</div></td>
    <td><input type="text" name="l_version" value="<?php if(isset($array[4]) and $i==0) echo $array[4]; //假如网页时第一次打开则 显示上次修改的值 ?>"></td>
  </tr>
  <tr>
    <td><div align="right">phonelistversion version:</div></td>
    <td><input type="text" name="p_version" value="<?php if(isset($array[5]) and $i==0) echo $array[5]; //假如网页时第一次打开则 显示上次修改的值 ?>"></td>
  </tr>
  <tr>
    <td><div align="right">mediadecodelib name:</div></td>
    <td><input name="m_name" type="text" size="60" value="<?php if(isset($array[6]) and $i==0) echo $array[6]; //假如网页时第一次打开则 显示上次修改的值 ?>"></td>
  </tr>
  <tr>
  <td><div align="right">mediadecodelib url:</div></td>
    <td><input name="m_url" type="text" value="<?php if(isset($array[7]) and $i==0) echo $array[7]; //假如网页时第一次打开则 显示上次修改的值 ?>"></td>
  </tr>
    <tr>
  <td><div align="right">code:</div></td>
    <td><input name="code"   type="text" value="B589336602E3B7E131E222ED17FC91938B01351F"></td>
  </tr>
      <td><div align="right">pass:</div></td>
    <td><input name="pas" type="password" size="16" /></td>
  </tr>
    <td colspan="2"><div align="center"><input type="submit" name="submit" value="提 交" ><input type="submit" name="submit2" value="生 成" ></div></td>
    </tr>
</table></form><?php
    if(isset($_POST["submit"]) && $_POST["submit"]!="")
{
    $rs=$_POST;
    array_pop($rs);  //删除数组的最后一个单元  就是产出post[submit]
    foreach($rs as $k=>$v){
        $str.=$v."\r\n";     //写入文件  一个post的值为一行 \r\n在文本中换行
    }
    $fp2=fopen("1.txt","w");   //打开文件 
    fwrite($fp2,$str);        //写入文件
    $i++;            //用来证明网页不是第一次打开
    fclose($fp2);
    
    $a_version = $_POST['a_version'];
    $a_url = $_POST['a_url'];
    $s_version = $_POST['s_version'];
    $s_setup = $_POST['s_setup'];
    $l_version = $_POST['l_version'];
    $p_version = $_POST['p_version'];
    $m_name = $_POST['m_name'];
$m_url = $_POST['m_url'];
$code = $_POST['code'];
    $file=fopen("temp.html","r");  //打开文件 
    $fp=fread($file,filesize("temp.html")); //读取文件
$fp=str_replace("{content1}",$a_version,$fp);
$fp=str_replace("{content2}",$a_url,$fp);
$fp=str_replace("{content3}",$s_version,$fp);
$fp=str_replace("{content4}",$s_setup,$fp);
$fp=str_replace("{content5}",$l_version,$fp);
$fp=str_replace("{content6}",$p_version,$fp);
$fp=str_replace("{content7}",$m_name,$fp);
$fp=str_replace("{content9}",$code,$fp);
//计算哈希$type = 109;
function getFileSize($url)

$url = parse_url($url); 
if($fp = @fsockopen($url['host'],empty($url['port'])?80:$url['port'],$error))

fputs($fp,"GET ".(empty($url['path'])?'/':$url['path'])." HTTP/1.1\r\n"); 
fputs($fp,"Host:$url[host]\r\n\r\n"); 
while(!feof($fp))

$tmp = fgets($fp); 
if(trim($tmp) == '')

break; 
}else if(preg_match('/Content-Length:(.*)/si',$tmp,$arr))

return trim($arr[1]); 


return null; 
}else

return null; 


$sizes = getFileSize($m_name);
$size = intval($sizes);
$haxi = file_get_contents($m_name, False, null, 0, 4096).$size;
$bas = "[353]".$m_name."|".$type."|".$size."|".sha1($haxi)."[353]";
$m353 = "m353://1|".base64_encode($bas);       $fp=str_replace("{content8}",$m353,$fp);
   
    fclose($file); //关闭文件
    $file1=fopen("update2.xml","w"); //已打开的方式 新建一个网页
    fwrite($file1,$fp); //写入文件
    fclose($file1);//关闭文件

?>
<?php 
    if(isset($_POST["submit2"]) && $_POST["submit2"]!="")
{
$m_pas = $_POST['pas'];
 $file=fopen("update2.xml","r");  //打开文件 
    $fp=fread($file,filesize("update.xml")); //读取文件
$du = sha1($fp.$m_pas);
echo $du;
$fp=str_replace("B589336602E3B7E131E222ED17FC91938B01351F",$du,$fp);
    fclose($file); //关闭文件
    $file1=fopen("update2.xml","w"); //已打开的方式 新建一个网页
    fwrite($file1,$fp); //写入文件
    fclose($file1);//关闭文件
}
?>

解决方案 »

  1.   

    加入javascript代码直接调用一个函数,点击后直接refrash,自带的刷新方式。网上很多
      

  2.   

    呃 这不难吧   <a href=''><input type='submit' value='login'></input></a>   这样就是跳到当前页面等于刷新1下当前页面
      

  3.   

    把下面的php代码放到页面最开始的地方,就不用刷新了。
      

  4.   

    <input type="submit" name="submit2" value="生 成" onclick='window.location.reload()'>
      

  5.   

    <input type="submit" name="submit2" value="生 成" onclick='window.location.reload()'>
      

  6.   

    Goooooooooooooooooooooooooooooooooooooood
      

  7.   

    submit的时候你的<form>里的action属性写本页面的文件名就可以啊