如何在php中显示文本框中的结果

时间:2014-08-13 09:09:59

标签: php

我有这段代码,我想在第三个输入框中显示结果,而不是在输入框和孔页面中,我想知道我是否可以使用$ _GET ['$ vairbles']白化功能  注意:我是php编程的初学者

这是我的代码:

<?php

$email = "mail@somedomain.com";
if (isset($_GET['txt1']) and isset($_GET['txt2'])) if (!empty($_GET['txt1']) and!empty($_GET['txt2'])) {
    $tex1 = $_GET['txt1'];
    $tex2 = $_GET['txt2'];
    echo "They are all filled.<br>";
} else {
    echo "Please fill in first and second Fields";
}

shwor();

Function shwor() {
    global $email;
    global $tex1;
    global $tex2;
    $len1 = strlen($tex1);
    $len2 = strlen($tex2);
    if ($len1 and $len2 > 0) if ($tex1 == $tex2) echo "matched ";
    else echo "Does not match";
}
?>


<form action:"email.php" method="GET">
    <input 1 type="text" name="txt1"><br><br>
    <input 2 type="text" name="txt2"><br><br>
    <input 3 type="text" name="Result" value = "<?php shwor();?>"><br><br>
    <input type="submit" value="Check matches"><br>
</form>

1 个答案:

答案 0 :(得分:0)

一切正常,只是拼错了这一行:

<form action:"email.php" method="GET">

应该是:

<form action="email.php" method="GET">

..并记得将您的文件命名为email.php,将数据发送到文件本身;-)