沃梦达 / IT编程 / 前端开发 / 正文

HTML / PHP表单未发布(MYSQL)

参见英文答案 “Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP 28个我现在已经连续工作了12个小时的代码,今晚我放...

参见英文答案 > “Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP                                    28个
我现在已经连续工作了12个小时的代码,今晚我放弃了.但是,如果有人可以帮助我,那么变数太多了,我不知道什么是什么.基本上我要做的是有一个带有24个复选框和24个选项的HTML表单…但是,当我尝试测试它时,它将不会执行if语句中的内容…任何帮助表示赞赏!

HTML

<!DOCTYPE html>
<html>
<head>
<title>Girls Beginner 1 Skills</title>
</head>
<style>
 td,  th {
    border: 1px solid #ddd;
    text-align: center;
    padding: 8px;
}

 tr:nth-child(even){}

 tr:hover {background-color: #ddd;}

 th {
    padding-top: 12px;
    padding-bottom: 12px;
    background-color: #2196F3;
    color: white;
 }
input[type=checkbox]
{
  /* Double-sized Checkboxes */
  -ms-transform: scale(3); /* IE */
  -moz-transform: scale(3); /* FF */
  -webkit-transform: scale(3); /* Safari and Chrome */
  -o-transform: scale(3); /* Opera */
  padding: 10px;
}
select {
    text-align: center;
    height: 40px;
    line-height: 40px;
    border: 1px solid #ccc;
    width: 200px;
}
.checkboxtext
{
  /* Checkbox text */
  font-size: 110%;
  display: inline;
}

input[type=submit] {
    padding:20px 160px; 
    background:#69F0AE; 
    border:30;
    font-family:Calibri;
    font-size: 30px;
    cursor:pointer;
    -webkit-border-radius: 5px;
    border-radius: 10px; 
}
</style>
<body background = "backg.png">
<h1 align ="center">Girls Beginner 1 Skills</h1>
<form action="S_eval_send.php" method="get">
<table border="1" align="center" bgcolor="#ffff99" width="700">
<tr>
<th>Bars</th>
<th>Skill</th>
<th>Form</th>
</tr>
<tr><td><h2>5 Pull-Ups in Pike Position</h4><br><p><h4>(Feet supported on a mat)</h4></p><br><br><br><br></td>
<td><h4><input type="checkbox" name="skill1" value="Skill"> </h4><br></td>
<td><h4><select name="form1" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<tr><td><h2>Hollow-Hold Plank</h4><br><p><h4>(On low bar)</h4></p><br><br><br></td>
<td><h4><input type="checkbox" name="skill2" value="Skill"> </h4><br></td>
<td><h4><select name="form2" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<tr><td><h2>Walk-Up Pullover</h4><br><p><h4>(Using a wedge mat)</h4><br><br><br></p></td>
<td><h4><input type="checkbox" name="skill3" value="Skill"> </h4><br></td>
<td><h4><select name="form3" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<td><h2>Front Support Hollow Hold</h4><br><p><h4>(5 Seconds)</h4></p><br><br><br></td>
<td><h4><input type="checkbox" name="skill4" value="Skill"> </h4><br></td>
<td><h4><select name="form4" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<td><h2>Glides in Hollow Position</h4><br><p><h4>(Using a glider)</h4></p><br><br></td>
<td><h4><input type="checkbox" name="skill5" value="Skill"> </h4><br></td>
<td><h4><select name="form5" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
</table>
<table border="1" align ="center" bgcolor ="ffb3b3" width="700">
<tr>
<th>Beam</th>
<th>Skill</th>
<th>Form</th>
</tr>
<tr><td><h2>Walking in Releve</h2><p><h4>(Forward/Sideways)</h4></p></td>
<td><h4><input type="checkbox" name="skill6" value="Skill"> </h4><br></td>
<td><h4><select name="form6" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<tr><td><h2>Walk Backwards</h4><p><h4>(Flat Feet)</h4></p></td>
<td><h4> <input type="checkbox" name="skill7" value="Skill"> </h4><br></td>
<td><h4><select name="form7" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<tr><td><h2>Straddle "L" Hold</h4><p><h4>(3 seconds)</h4></p></td>
<td><h4> <input type="checkbox" name="skill8" value="Skill"> </h4><br></td>
<td><h4><select name="form8" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<td><h2>Arabesque</h4><p><h4>(5 Seconds)</h4></p></td>
<td><h4> <input type="checkbox" name="skill9" value="Skill"> </h4><br></td>
<td><h4><select name="form9" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<td><h2>High Kicks</h4><p><h4>(Front/Back)</h4></p></td>
<td><h4> <input type="checkbox" name="skill10" value="Skill"> </h4><br></td>
<td><h4><select name="form10" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<td><h2>Pile to Squat</h4><p><h4></h4></p></td>
<td><h4> <input type="checkbox" name="skill11" value="Skill"> </h4><br></td>
<td><h4><select name="form11" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
</table>
<table border="1" align="center" bgcolor ="80ffcc" width="700">
<tr>
<th>Floor</th>
<th>Skill</th>
<th>Form</th>
</tr>
<tr><td><h2>Forward Roll</h4><p><h4>(4 clear positions)</h4></p></td>
<td><h4> <input type="checkbox" name="skill12" value="Skill"> </h4><br></td>
<td><h4><select name="form12" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<tr><td><h2>3/4th of a handstand</h4><p><h4>(From one leg to the other)</h4></p></td>
<td><h4> <input type="checkbox" name="skill13" value="Skill"> </h4><br></td>
<td><h4><select name="form13" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<tr><td><h2>Bridge from Floor</h4><p><h4>(5 seconds with straight elbows)</h4></p></td>
<td><h4> <input type="checkbox" name="skill14" value="Skill"> </h4><br></td>
<td><h4><select name="form14" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<td><h2>Familiar with Floor</h4><p><h4>Terms:</h4></p></td>
<td><h4> <input type="checkbox" name="skill15" value="Skill"> </h4><br></td>
<td><h4><select name="form15" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<td><h3>a.) Straddle</h4></td>
<td><h4> <input type="checkbox" name="skill16" value="Skill"> </h4><br></td>
<td><h4> <select name="form16" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<td><h3>b.) Pike</h4></td>
<td><h4> <input type="checkbox" name="skill17" value="Skill"> </h4><br></td>
<td><h4> <select name="form17" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<td><h3>c.) Hollow</h4></td>
<td><h4> <input type="checkbox" name="skill18" value="Skill"> </h4><br></td>
<td><h4> <select name="form18" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<td><h3>d.) Arch</h4></td>
<td><h4> <input type="checkbox" name="skill19" value="Skill"> </h4><br></td>
<td><h4> <select name="form19" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<td><h3>e.) Tuck</h4></td>
<td><h4> <input type="checkbox" name="skill20" value="Skill"> </h4><br></td>
<td><h4> <select name="form20" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<td><h3>f.) Line</h4></td>
<td><h4> <input type="checkbox" name="skill21" value="Skill"> </h4><br></td>
<td><h4> <select name="form21" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<td><h3>g.) Splits</h4></td>
<td><h4> <input type="checkbox" name="skill22" value="Skill"> </h4><br></td>
<td><h4> <select name="form22" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
</table>
<table border="1" align ="center" bgcolor ="#80b2ff" width="700">
<tr>
<th>Vault</th>
<th>Skill</th>
<th>Form</th>
</tr>
<tr><td><h2>Running</h2></td>
<td><h4> <input type="checkbox" name="skill23" value="Skill"> </h4><br></td>
<td><h4> <select name="form23" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
<tr><td><h2>Correct Jump onto<br>Panel</h4></td>
<td><h4> <input type="checkbox" name="skill24" value="Skill"> </h4><br></td>
<td><h4> <select name="form24" required>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
        </select></td></tr>
</table>

<br>
<div align="center" >
<input type="submit"  value="Send to Server" name="submit" >
</div>
</form>

</body>
</html>

PHP

<?php

define('DB_NAME', 'forms1');
define('DB_USER', 'test');
define('DB_PASSWORD', 'greatness');
define('DB_HOST', 'localhost');

$link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD,DB_NAME);

if(!$link){
    die('Could not connect: ' . mysql_error());
}

$db_selected = mysqli_select_db($link, DB_NAME);


if(isset($_POST['submit'])){
$skill1 = $_POST['skill1'];
$skill2 = $_POST['skill2'];
$skill3 = $_POST['skill3'];
$skill4 = $_POST['skill4'];
$skill5 = $_POST['skill5'];
$skill6 = $_POST['skill6'];
$skill7 = $_POST['skill7'];
$skill8 = $_POST['skill8'];
$skill9 = $_POST['skill9'];
$skill10 = $_POST['skill10'];
$skill11 = $_POST['skill11'];
$skill12 = $_POST['skill12'];
$skill13 = $_POST['skill13'];
$skill14 = $_POST['skill14'];
$skill15 = $_POST['skill15'];
$skill16 = $_POST['skill16'];
$skill17 = $_POST['skill17'];
$skill18 = $_POST['skill18'];
$skill19 = $_POST['skill19'];
$skill20 = $_POST['skill20'];
$skill21 = $_POST['skill21'];
$skill22 = $_POST['skill22'];
$skill23 = $_POST['skill23'];
$skill24 = $_POST['skill24'];
$form1 = $_POST['form1'];
$form2 = $_POST['form2'];
$form3 = $_POST['form3'];
$form4 = $_POST['form4'];
$form5 = $_POST['form5'];
$form6 = $_POST['form6'];
$form7 = $_POST['form7'];
$form8 = $_POST['form8'];
$form9 = $_POST['form9'];
$form10 = $_POST['form10'];
$form11 = $_POST['form11'];
$form12 = $_POST['form12'];
$form13 = $_POST['form13'];
$form14 = $_POST['form14'];
$form15 = $_POST['form15'];
$form16 = $_POST['form16'];
$form17 = $_POST['form17'];
$form18 = $_POST['form18'];
$form19 = $_POST['form19'];
$form20 = $_POST['form20'];
$form21 = $_POST['form21'];
$form22 = $_POST['form22'];
$form23 = $_POST['form23'];
$form24 = $_POST['form24'];
$value1 = "George";
$value2 = "Poulos";
$value  = "15";
echo "Hello";

$sql = "INSERT INTO girls_beg_1_eval (client_id,first_name,last_name,skill1,skill2,skill3,skill4,skill5,skill6,
skill7,skill8,skill9,skill10,skill11,skill12,skill13,skill14,skill15,skill16,skill17,skill18,skill19,skill20,skill21,skill22,
skill23,skill24,form1,form2,form3,form4,form5,form6,
form7,form8,form9,form10,form11,form12,form13,form14,form15,form16,form17,form18,form19,form20,form21,form22,
form23,form24) VALUES ('$value','$value1','$value2','$skill1', '$skill2','$skill3','$skill4','$skill5','$skill6','$skill7','$skill8',
'$skill9','$skill10','$skill11','$skill12','$skill13','$skill14','$skill15','$skill16','$skill17','$skill18','$skill19'
,'$skill20','$skill21','$skill22','$skill23','$skill24','$form1', '$form2','$form3','$form4','$form5','$form6','$form7','$form8',
'$form9','$form10','$form11','$form12','$form13','$form14','$form15','$form16','$form17','$form18','$form19'
,'$form20','$form21','$form22','$form23','$form24')";

if(!mysqli_query($link, $sql)){
    die('Error: ' . mysql_error());
}



}

mysqli_close($link);

?>

解决方法:

您的表单标签在方法中使用GET …检查出来..将其设置为发布

<form action="S_eval_send.php" method="post">

本文标题为:HTML / PHP表单未发布(MYSQL)