dougaicha5258 2011-12-20 02:27
浏览 32
已采纳

在IE中奇怪的重复php fwrite

I've been having a really tough time fixing an error, where I submit an html form and take the information from that form and use it in a php script where I save it to a file. In chrome and Firefox, it saves the data fine, no problems. However, in IE, either the forms submits weird, or the php messes up, where it repeats saving the data 10 times. So instead of "Test", I'm getting "TestTestTestTestTest..ect"

Does anybody know why this would occur in IE only?

The general code (not all included.. however, it's mostly just repeats of this):

<form id="form1" action="createProf.php" method="post">

<input type="radio" style="position:absolute; top: 218px; left: 560px;" id="female" name="gender" value="female"/>
<input type="radio" style="position:absolute; top: 187px; left: 560px;" id="male"   name="gender" value="male"/>
<input type="text" id="year" name="year" size="4" value="Year" style="position:absolute; top: 416px; left: 640px;"/>
</form>

    //php code//
$gender = htmlspecialchars($_POST['gender']);
$acc = fopen($file, 'r') or die("cant open file");
//other reading code and other stuff ehre
fwrite($acc, $data);
fclose($acc);

Thanks, and if more is needed to help, I'm willing to add more on.

  • 写回答

1条回答 默认 最新

  • dongwaner1367 2011-12-20 21:30
    关注

    Apparently I said something wrong for people not to answer me and to -1 my post.

    Anyways, I found an answer to my problem where I just check to see if the data from the last save is already there, which then I don't write and close the file. I wish there was a cleaner way, but I guess for now this is what I have to use.

    if(strpos(fread($acc, filesize($file)), "identification_string")==false){ 
    //Write to file
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么