0

我已阅读发布的多个问题,但无法找到直接回答我想要完成的问题的问题。我在其他发布答案中尝试了几个建议,但仍然没有我想要的结果。

我正在尝试从 single_name 表单获取输入以填充到我的示例页面(single2.php)上。

这是 single_name.php 上的代码:

<form name="singlename" method="post" action="./single2.php" id="Form1" onsubmit="return Validatesinglename(this)">
<div id="wb_Text1" style="position:absolute;left:10px;top:15px;width:81px;height:16px;z-index:0;text-align:left;"><span style="color:#000000;font-family:Arial;font-size:13px;">Name:</span></div><input type="text" id="name" style="position:absolute;left:101px;top:15px;width:198px;height:23px;line-height:23px;z-index:1;" name="name" value="" autocomplete="off">
<div id="wb_Text2" style="position:absolute;left:10px;top:45px;width:81px;height:16px;z-index:2;text-align:left;"><span style="color:#000000;font-family:Arial;font-size:13px;">Gender:</span></div><input type="text" id="gender" style="position:absolute;left:101px;top:45px;width:198px;height:23px;line-height:23px;z-index:25;" name="Gender" value="">
<div id="wb_Text3" style="position:absolute;left:10px;top:75px;width:81px;height:16px;z-index:4;text-align:left;"><span style="color:#000000;font-family:Arial;font-size:13px;">Date of Birth:</span></div><input type="date" id="dob" style="position:absolute;left:101px;top:75px;width:198px;height:23px;line-height:23px;z-index:5;" name="dob:" value="" autocomplete="off">
<div id="wb_Text4" style="position:absolute;left:10px;top:105px;width:81px;height:16px;z-index:6;text-align:left;"><span style="color:#000000;font-family:Arial;font-size:13px;">Message:</span></div><input type="text" id="message" style="position:absolute;left:101px;top:105px;width:198px;height:23px;line-height:23px;z-index:7;" name="Message:" value="" autocomplete="off">
<input type="submit" id="Button1" name="" value="Send" style="position:absolute;left:101px;top:135px;width:96px;height:25px;z-index:8;">
<input type="reset" id="Button2" name="" value="Reset" style="position:absolute;left:207px;top:136px;width:96px;height:25px;z-index:9;">
</form>

这是 single2.php 上的内容:

<div id="wb_Text1" style="position:absolute;left:428px;top:514px;width:515px;height:391px;text-align:center;z-index:29;">
   echo $_POST["name"]; 
}
?></strong></span><span style="color:#000000;font-family:Chancellor;font-size:19px;">
<br>
<br>
Local Origin of Name:&nbsp; Unique and Original<br>From the name
<?php
{
   echo $_POST["name"]; 
}    <br>
<br>
Evaluation Meaning:&nbsp; Festive, Joyous
<br>
<br>
<strong>&#0042;</strong> Emotional Spectrum <strong>&#0042;</strong>
<br>
Up front and honest
<br>
<strong>&#0042;</strong> Personal Integrity <strong>&#0042;</strong>
<br>
Friends know that
<?php
{
   echo $_POST["name"]; 
?>
can be called on in a crisis.
<br>
<strong>&#0042;</strong> Personality <strong>&#0042;</strong>
<br>
Life in the fast lane, tempered by common sense.
<br>
<strong>&#0042;</strong>&nbsp; Relationships <strong>&#0042;</strong>
<br>
Stays true and loyal
<br>
<br>

<?php
{
   echo $_POST["name"]; 
}
?>    is a 
<?php
{
   echo $_POST["gender"]; 
}
?>
<br>
<br>
{
   echo $_POST["name"]; 
}
?>
was born 
<?php
{
   echo $_POST["dob"]; 
}
?>
<br>
<br>
</span>
<span style="color:#000000;font-family:Georgia;font-size:27px;"><strong><em>
<?php
{
   echo $_POST["message"]; 
}
?></em></strong>
</span>

我可以在每个地方发布“姓名”,但“性别”、“出生日期”和“消息”不发布。

任何帮助将不胜感激。

4

6 回答 6

2
 name="name"
 name="Gender" 
 name="dob:"
 name="Message:" 

所以,帖子应该是相同的情况

$_POST['name']
$_POST['Gender']
$_POST['dob:']
$_POST['Message:']
于 2013-05-26T00:09:03.170 回答
1

你在 single_name.php 上拼错了你的名字

name="Gender"
name="dob:"
name="Message:"

必须使用相同的名称(小写不带冒号)

于 2013-05-26T00:06:37.800 回答
0
<input name="Gender" >#name should be 'gender' not 'Gender'
<input name="dob:" >#name should be 'dob' not 'dob:'
<input name="Message:" >#name should be 'message' not be 'Message:'

将来,您输入的名称name应与您的帖子值匹配,并且区分大小写,因此 'Gender' !== 'gender' 等等

于 2013-05-26T00:08:22.957 回答
0

您的姓名与所述不符。查看发生了什么的简单方法是在 Single_2.php 页面中添加一个调试标记: print_r($_POST); 这会在使用时“弄乱你的页面”,但会让你看到整个 $_POST 数组,其中包含正在遇到的键和数据。然后你可以检查名称等。

要以更易读的格式查看数组,请单击鼠标右键并“检查元素”

于 2013-05-26T00:13:04.387 回答
0

将以下更正的代码剪切并粘贴到您的应用程序中。它已经过测试并且工作正常。

“single_name.php”如下:


<form id="Form1" action="./single2.php" method="post" name="singlename" onsubmit="return Validatesinglename(this)">

<div id="wb_Text1" style="position: absolute; left: 10px; top: 15px; width: 81px; height: 16px; z-index: 0; text-align: left;">
    <span style="color: #000000; font-family: Arial; font-size: 13px;">Name:</span></div>
<input id="name" autocomplete="off" name="name" style="position: absolute; left: 101px; top: 15px; width: 198px; height: 23px; line-height: 23px; z-index: 1;" type="text" value="">

<div id="wb_Text2" style="position: absolute; left: 10px; top: 45px; width: 81px; height: 16px; z-index: 2; text-align: left;">
    <span style="color: #000000; font-family: Arial; font-size: 13px;">Gender:</span></div>
<input id="gender" name="gender" style="position: absolute; left: 101px; top: 45px; width: 198px; height: 23px; line-height: 23px; z-index: 25;" type="text" value="">

<div id="wb_Text3" style="position: absolute; left: 10px; top: 75px; width: 81px; height: 16px; z-index: 4; text-align: left;">
    <span style="color: #000000; font-family: Arial; font-size: 13px;">Date 
    of Birth:</span></div>
<input id="dob" autocomplete="off" name="dob" style="position: absolute; left: 101px; top: 75px; width: 198px; height: 23px; line-height: 23px; z-index: 5;" type="date" value="">

<div id="wb_Text4" style="position: absolute; left: 10px; top: 105px; width: 81px; height: 16px; z-index: 6; text-align: left;">
    <span style="color: #000000; font-family: Arial; font-size: 13px;">Message:</span></div>
<input id="message" autocomplete="off" name="message" style="position: absolute; left: 101px; top: 105px; width: 198px; height: 23px; line-height: 23px; z-index: 7;" type="text" value="">

<input id="Button1" name="" style="position: absolute; left: 101px; top: 135px; width: 96px; height: 25px; z-index: 8;" type="submit" value="Send">
<input id="Button2" name="" style="position: absolute; left: 207px; top: 136px; width: 96px; height: 25px; z-index: 9;" type="reset" value="Reset">
</form>

和“single2.php”如下:

<div id="wb_Text1" style="position: absolute; left: 428px; top: 514px; width: 515px; height: 391px; text-align: center; z-index: 29;">

<?php echo $_POST["name"];  ?>  
</strong></span><span style="color: #000000; font-family: Chancellor; font-size: 19px;">
<br><br>
Local Origin of Name:&nbsp; Unique and Original<br>From the name 
<?php echo $_POST["name"];?>
<br>
<br>
Evaluation Meaning:&nbsp; Festive, Joyous
<br>
<br>
<strong>&#0042;</strong> Emotional Spectrum <strong>&#0042;</strong>
<br>
Up front and honest
<br>
<strong>&#0042;</strong> Personal Integrity <strong>&#0042;</strong>
<br>
Friends know that 
<?php echo $_POST["name"]; ?> 
can be called on in a crisis. <br><strong>&#0042;</strong> Personality <strong>&#0042;</strong>
<br>Life in the fast lane, tempered by common sense. <br><strong>&#0042;</strong>&nbsp; 
Relationships <strong>&#0042;</strong> <br>Stays true and loyal <br><br>
</span></div>

<?php //following for debug
echo 'Name is : '.$_POST["name"].'<br>'; 
echo 'Gender is : '.$_POST["gender"].'<br>'; 
echo 'Date of Birth is : '.$_POST["dob"].'<br>'; 
echo 'Message is : '.$_POST["message"].'<br>'; 
?>
于 2013-05-26T01:27:11.613 回答
0

尝试插入这样的调试代码并查看 POST 数组中存储了哪些键:

echo '<pre>'
var_dump($_POST);

并且尽量不要在你的输入名称中使用特殊符号,因为这个例子不能正常工作:

$_POST['dob:'] = 'somevalue';

foreach($_POST as $key=>$value){
    $$key = $value;
}
于 2013-05-26T00:52:30.963 回答