我已经广泛地浏览了这个网站,尽管我觉得我知道自己在做什么;我一定是弄错了,因为我似乎无法找到我的错误。
<?php
if $myfile = fopen("submits/mydata.txt", "w")
(isset($_POST['name']) && isset($_POST['ign']) && isset($_POST['email']) && isset($_POST['op16-18']) && isset($_POST['op19-24']) && isset($_POST['op25+']) && isset($_POST['role'])) {
$data = $_POST['name'] . '-' . $_POST['ign'] . '-' . $_POST['email'] . '-' . $_POST['op16-18'] . '-' . $_POST['op19-24'] . '-' . $_POST['op25+'] . '-' . $_POST['role'] "\n";
$ret = file_put_contents('submits/mydata.txt', $data, FILE_APPEND | LOCK_EX);
if ($ret === false) {
die('There was an error writing this file');
} else {
echo "$ret bytes written to file";
}
} else {
die('no post data to process');
}
以上是正在使用的html,以下是表格:html
<form action="" method="">
<?php include 'form.php' ;?>
<label class=""><b></b> </label><br><br><br><br><br><br>
<label>Real name</label><br>
<input name="name" class="input-box" type="text" name="firstname" placeholder="Name"><br><br><br>
<label>Game name</label><br>
<input name="ign"class="input-box" type="text" name="lastname" placeholder="Alias"><br><br><br>
<label> Email </label>
<br><input name="email" class="input-box form-email" type="email" name="comment" placeholder="OPTIONAL"><br><br><br><br>
<label class="">Age:</label><br><br>
<span class="radio-age">
<div class="container">
<ul>
<li>
<input name="op16-18" type="radio" id="f-option" name="selector">
<label for="f-option">16-18</label>
<div class="check"></div>
</li>
<li>
<input name="op19-24" type="radio" id="s-option" name="selector">
<label for="s-option">19-24</label>
<div class="check"><div class="inside"></div></div>
</li>
<li>
<input name="op25+" type="radio" id="t-option" name="selector">
<label for="t-option">25+</label>
<div class="check"><div class="inside"></div></div>
</li>
</ul>
</div>
</span>
<div class="dropdown">
<span class="select-span">Tier Select</span><br>
<div class="dropdown-content">
<select name="tier">
<option value="bronze"> Bronze </option>
<option value="silver"> Silver </option>
<option value="gold"> Gold </option>
<option value="platinum"> Platinum </option>
<option value="diamond"> Diamond </option>
<option value="master"> Master </option>
<option value="grandmaster"> Grandmaster </option>
</select>
</div>
</div><br><br><br><br><br><br>
<div class="dropdown">
<span class="select-span">Role Select</span><br>
<div class="dropdown-content">
<select name="role">
<option value="bronze"> Healer </option>
<option value="silver"> Tank </option>
<option value="gold"> Damage </option>
</select>
</div>
</div><br><br><br><br><br><br>
<input class="submit" class="submit" type="submit" name="submit" value="Submit">
</form>
如果有人发现我的格式错误或完全滥用功能,我觉得删除内容效率很低。我真的很感激这些明智的话语。
答案 0 :(得分:0)
这是一个开始。就像notepadd ++和w3school一样。
if (
($myfile = fopen("submits/mydata.txt", "w")) &&
isset($_POST['name']) &&
isset($_POST['ign']) &&
isset($_POST['email']) &&
isset($_POST['op16-18']) &&
isset($_POST['op19-24']) &&
isset($_POST['op25+']) &&
isset($_POST['role'])
) {
$data = $_POST['name'] . '-' . $_POST['ign'] . '-' . $_POST['email'] . '-' . $_POST['op16-18'] . '-' . $_POST['op19-24'] . '-' . $_POST['op25+'] . '-' . $_POST['role']. "\n";
$ret = file_put_contents('submits/mydata.txt', $data, FILE_APPEND | LOCK_EX);
if ($ret === false) {
die('There was an error writing this file');
} else {
echo "$ret bytes written to file";
}
/*
*
*/
} else {
die('no post data to process');
}
Netbeans说没关系(没有格式化错误)我的部分