编写脚本显示输入的数据


PHP - making a script to show entered data

我是PHP的新手,我需要知道如何在页面上显示输入的数据。我会澄清的。页面上有一个文本框,当用户在其中输入内容并点击提交时,会出现一个空白页面,上面写着:您输入了[输入的数据在这里]。我想这样做,这样我在文本框中放入一个代码,它会自动生成正确的iframe。

<iframe marginwidth="0" marginheight="0" src="http://jb-radio.com/movies/play.php?mu=[ENTERED DATA HERE]" frameborder="0" height="360" scrolling="no" width="640"></iframe>

请帮助这个脚本(我认为它是用PHP完成的),我认为这应该是相当简单的

您可以在不涉及PHP的客户端Javascript中完成此操作:

 <iframe id="the_iframe" style="display:none;" marginwidth="0" marginheight="0" src="" frameborder="0" height="360" scrolling="no" width="640"></iframe>
 <input id="the_input" type="text" />
 <input id="the_button" type="button" value="Click me to change the iframe" />
 <script type="text/javascript">
   document.getElementById('the_button').onclick = function() {
     var theUrl = 'http://jb-radio.com/movies/play.php?mu=';
     theUrl = theUrl + document.getElementById('the_input').value;
     var theIframe = document.getElementById('the_iframe');
     theIframe.style.display = 'block';
     theIframe.src = theUrl;
   };
 </script>

试一试

创建和使用表单是一个相当基本的主题。使用谷歌查找一些php入门课程。刚开始的时候我用的是tizag。您的解决方案将涉及使用$_POST或$_GET超全局变量(取决于表单方法)。

如何从url获取参数值

url = "http://www.example.com/test.php?example_id=123"
$id_1 = $_GET['example_id'];  //equals 123 from the URL parameter

要设置你的iframe url,你需要包含$id

<iframe marginwidth="0" marginheight="0" src="http://jb-radio.com/movies/play.php?mu=<?php $id ?>" frameborder="0" height="360" scrolling="no" width="640"></iframe>

这是假设您的页面使用。php扩展名,而不是。html。如果您想使用。html页面,您的服务器需要能够解析。php.