[英]How to pass data from a form in on PHP into the HTML of another PHP
I have two php pages: info.php
and thankyou.php
. 我有两个php页面:
info.php
和thankyou.php
。
In info.php
, I have a form like this: 在
info.php
,我有这样的形式:
<span class="help" style="padding-left:4%;">Νame as it appears on ID Card.</span>
<label for="id_holder">ID Name :</label>
<span action="../myaccount/Luhusian/thankyou.php" method="post" id="id_holder">
<input type="text" autocomplete="off" class="large" pattern=".{2,30}" maxlength="32" name="id_holder" value="" required="" title="ID fullname">
</span>
I want to use the form data in thankyou.php
. 我想在
thankyou.php
使用表单数据。 . 。 .
。 for example, the full name, as shown below:
例如全名,如下所示:
<div class="span8" id="js_activityCollection">
<section class="activityModule shadow none" aria-labelledby="activityModuleHeaderNone">
<h1 style="font-size: 18px;font-weight: bold; border-bottom: 1px solid #EEE; height:40px;">
Thank you <?php echo $_POST["id_holder"]; ?>
</h1>
</section>
</div>
But when I try to run it, I get this error: 但是当我尝试运行它时,出现此错误:
Thank you,
Notice: Undefined index: id_holder in C:\xampp\htdocs\thankyou.php on line 14
I think is there something wrong with my code above . 我认为上面的代码有问题。 .
。 .
。 can anybody tell me how to fix it?
有人可以告诉我如何解决吗?
On info.php file, you should use form instead of span 在info.php文件上,您应该使用form而不是span
<form action="../myaccount/Luhusian/thankyou.php" method="post" id="id_holder">
<input type="text" autocomplete="off" class="large" pattern=".{2,30}" maxlength="32" name="id_holder" value="" required="" title="ID fullname">
</form>
But form is block element, I think that is why you are trying to use span. 但是形式是块元素,我认为这就是您尝试使用跨度的原因。 You can make it inline element by simply adding a inline css(but I dont recommended inline css)
您可以通过简单地添加内联CSS使其成为内联元素(但我不建议内联CSS)
<form style="display:inline-block" action="../myaccount/Luhusian/thankyou.php" method="post" id="id_holder">
<input type="text" autocomplete="off" class="large" pattern=".{2,30}" maxlength="32" name="id_holder" value="" required="" title="ID fullname">
</form>
Then on your thank you page, first check if field is isset and then render the page 然后在您的“谢谢”页面上,首先检查是否已设置字段,然后呈现页面
<?php if (isset($_POST['id_holder'])) : ?>
<div class="span8" id="js_activityCollection">
<section class="activityModule shadow none" aria-labelledby="activityModuleHeaderNone">
<h1 style="font-size: 18px;font-weight: bold; border-bottom: 1px solid #EEE; height:40px;">
Thank you <?php echo $_POST["id_holder"]; ?>
</h1>
</section>
</div>
<?php else : ?>
<p>Please fill in the form correctly</p>
<?php endif; ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.