[英]Writing form input in .txt using Php
如何复制表格框和PHP中的代码以“抓住新添加的表格框”? 我打算创建4个表单框(电子邮件,密码,联系方式,简历),但我已经陷入了第二个表单框。 代码:
<form action="#" method="post">
<input type="text" name="email" class="emailSubmitSidebar" placeholder=" Your Email">
<input type="text" name="password" class="password" placeholder="Password">
<input type="submit" name="submit" class="submitButton">
</form>
<?php
if(isset($_POST["submit"]))
{
$fileHandle = fopen('info.txt', 'w+')
OR die ("Can't open file\n");
$email=$_POST["email"];
$password=$_POST["password"];
$result = fwrite ($fileHandle, $email, $password);
if ($result)
{
print '<script type="text/javascript">';
print 'alert("Email added!")';
print '</script>';
} else {
print '<script type="text/javascript">';
print 'alert("Email not added!")';
print '</script>';
};
fclose($fileHandle);
}
?>
PHP代码不断失败,为此直接解决?
更改此行:
$result = fwrite ($fileHandle, $email."-".$password);
fwrite
使用单个字符串的一个参数,不能传递两个参数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.