gpt4 book ai didi

javascript - 隐藏div(显示:none) and form inputs play role with PHP?

转载 作者:搜寻专家 更新时间:2023-10-31 22:04:06 28 4
gpt4 key购买 nike

我正在生成(可能是困难的)输入集,范围从 1 到 15。

用户从下拉列表中选择输入的数量。然后显示适当的输入集,如 select_num_fields.php 中所示。

<?php 
// Parse the form data and add inventory item to the system
$messageDeveloper = "";
if (isset($_POST['url'])) {

$commaVar = ",";
$varCharVar = "VARCHAR(255) NOT NULL";
$pid = mysqli_real_escape_string($db_conx, $_POST['thisID']);
$url = preg_replace("/[^A-Za-z0-9?!]/",'', $_POST['url']);
$cleanOne = preg_replace("/[^A-Za-z0-9?!]/",'', $_POST['usernameOne']);
echo "<pre>";
var_dump($cleanOne);
echo "</pre><br>";


// ------1---------------------------------------------------------------------------------------------------------------------------------------------------
if (isset($cleanOne)) {
// filter everything but numbers and letters preg_replace
$usernameOne = " $cleanOne $varCharVar $commaVar";

}
else if(!isset($cleanOne)) {

$usernameOne = "";

}
//other ifs go here to complete a tr

// See if that product name is an identical match to another product in the system
$sql = "
CREATE TABLE IF NOT EXISTS $url (
id int(11) NOT NULL auto_increment,
$url varchar(255) NOT NULL,
$usernameOne
created date,
PRIMARY KEY (id),
UNIQUE KEY $url ($url)
)
";
echo "<pre>";
var_dump($sql);
echo "</pre><br>";
$result = mysqli_query($db_conx,$sql) or trigger_error("Query Failed! SQL: $sql - Error: ".mysqli_error(), E_USER_ERROR);


if ($query === TRUE) {
header("location: creator_test.php?tableDone=1");
exit();
} else {
header("location: creator_test.php?tableDone=0");
exit();
}
}
?>

<form action="creator_test.php" enctype="multipart/form-data" name="myForm" id="myForm" method="post">
<h3 style="padding-left:10px;">&darr; Add New Page To List &darr;</h3>
<h4>Create page table for database</h4>
<div id="colorBlocks">

<?php include_once("includes/developer/make_table_developer_form.php");?>
<br /><br /><span style="clear:both;">Select number of variables and name them. This will also determine table structure.</span>
<br />
<br />
<?php include_once("includes/developer/select_num_fields.php");?>


<input type="submit" name="button" id="button" value="Add This Item Now" />
</form>

ma​​ke_table_developer_form.php

<p id="di1" style="clear:both;display:table;margin-bottom:15px;margin-top:0;">
<p id="di2" style="float:left;width:55px;text-align:right;margin-top:0;">
URL:
</p>
<p id="di3" style="float:left;margin-left:10px;margin-top:0;">
<input name="url" type="text" id="url" size="64" />
</p>
</p>
<p id="di4" style="clear:both;display:table;margin-bottom:15px;margin-top:0;">

<p id="di5" style="float:left;width:55px;text-align:right;margin-top:0;">
Status:
</p>
<p id="di6" style="float:left;margin-left:10px;margin-top:0;">
<select name="status" id="status">
<option value="Ready">Ready</option>
<option value="Live">Live</option>
<option value="Hold">Hold</option>
</select>
</p>
</p>

select_num_fields.php

<select id="selectMe">
<option value="div1">1</option>
<option value="div2">2</option>
<option value="div3">3</option>
<option value="div4">4</option>
<option value="div5">5</option>
<option value="div6">6</option>
<option value="div7">7</option>
<option value="div8">8</option>
<option value="div9">9</option>
<option value="div10">10</option>
<option value="div11">11</option>
<option value="div12">12</option>
<option value="div13">13</option>
<option value="div14">14</option>
<option value="div15">15</option>
</select>
<br><br><br>

<div id="div1" class="group" >
<input name="usernameOne" type="text" id="usernameOne" size="40"/><br />
</div>

<div id="div2" class="group" >
<input name="usernameOne" type="text" id="usernameOne" size="40"/><br />
<input name="usernameTwo" type="text" id="usernameTwo" size="40"/><br />
</div>//ect.

我的问题是没有传递任何用户名变量。请记住,我正在运行的 sciprt 使 div1 display:nonediv2 display:none;

因此,当我转储变量以查看发生了什么时,传递了第一个变量 url,但没有传递用户名。使用此方法显示输入有问题吗?我错过了什么吗?

谢谢。

最佳答案

很难准确理解您的代码在做什么,但希望这对您有所帮助:

HTML 样式对张贴的字段没有影响,所以这不是问题所在。如果设置了“已禁用”属性,将阻止通过表单发布字段。

问题的一部分可能是您有两个同名输入 (usernameOne)。如果您填写第一个但将第二个留空,则第二个空白字段将覆盖第一个。作为旁注,虽然您可以有多个具有相同名称的输入,但您不应该有多个具有相同 ID 的输入。元素的 ID 应该始终是唯一的。

关于javascript - 隐藏div(显示:none) and form inputs play role with PHP?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22265928/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com