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
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度