Skip to content

向php后台提交一个表单

zhanglei edited this page Nov 16, 2020 · 2 revisions

向php后台提交一个表单

本事例位于examples/load-request下

1.编写一个入口文件

<?php
$oSciter = new PHPSciter();
$oSciter->setResourcePath('file://' . __DIR__ . '/res/');
$oSciter->setWindowFrame(100, 100, 100, 100);
$oSciter->setWindowTitle('hello');
$oSciter->loadFile('index2.php');


$oSciter->setOption(PHPSciter::SCITER_SET_SCRIPT_RUNTIME_FEATURES,
PHPSciter::ALLOW_FILE_IO | PHPSciter::ALLOW_SOCKET_IO | PHPSciter::ALLOW_EVAL |
                               PHPSciter::ALLOW_SYSINFO);


$r = $oSciter->run(PHPSciter::SW_TITLEBAR | PHPSciter::SW_RESIZEABLE | PHPSciter::SW_MAIN | PHPSciter::SW_ENABLE_DEBUG
|PHPSciter::SW_CONTROLS);
var_dump($r);
?>

2.使用sciter执行引擎绘制一张表单

编写index2.php,用sciter绘制出一张表单,并且向index2.php中,发送get或者post的表单请求

<html>
<head>
    <title>Test</title>
    <style>

        form { flow:row(label,input); }
        form > label {white-space:nowrap;}
        form [required].error { border-right:0.25em red solid; }

    </style>
</head>
<body>

<form action="form.php?id=3" method="get">
    <label>First name:</label><input|text(first) required title="Must not be empty">
    <label>Second name:</label><input|text(second) required=".{2,}" title="Please enter 2 characters or more." >
    <button|submit>Submit</button>
</form>

<script type="text/tiscript">

</script>
</body>
</html>

弹出我们制作的表单

3.编写form.php 用来接收表单请求

由于php内核的var_dump函数并没有调用write_function 函数,所以我们无法将var_dump的内容输出到sciter的界面中,尽管我们可以输入输出重定向,但是再不同的操作系统中,这是一个麻烦的事情,但是幸运的是,他会输入到控制台上,我们可以透过控制台来进行调试

<?php
var_dump($_GET);
?>
<a href="index2.php">return2</a>

看!我们的控制台执行结果