点击html提交并运行php代码 [英] click submit in html and run php code

查看:140
本文介绍了点击html提交并运行php代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的html& PHP和我感谢您的帮助。我试图接受用户对网页的输入,然后在用户点击提交按钮后,向MySQL写入新记录。我使用的是Wordpress,所以标签不完全是教科书。

I am new to html & php and I appreciate your help. I am trying to accept user input into a webpage and then after the user clicks the submit button, write a new record out to MySQL. I am using Wordpress so the tags are not exactly textbook.

所以我的第一个问题是提交按钮看起来不会执行php代码。如果有人能够检查我如何将我的html字段名称传递给php变量以确保我处于正确的轨道,那么我也会很感激。感谢您的帮助!

So my first problem is that the submit button does not appear to execute the php code. I also would appreciate it if someone could check how I am passing my html field names to the php variables to make sure that I am on the right track. Thanks for your help!

html code to collect user input for fields on the form.....
<?php>
    if(isset($_POST['Submit'])) {
        $FName = $_POST['FName'];
        $MI = $_POST['MI'];
        $LName = $_POST['LName'];
....
?>
<form action="" method="post">
<input type="submit" name="Submit" value="Submit">


推荐答案

我认为阅读更多内容会更好关于它。查看 此处

I think it can be good to read a bit more about it. Check here.

无论如何,您需要说明要发布到的文件的名称:< input type =submitaction =file.phpname =Submit/ > 为例。

Anyway, you need to say the name of the file to post to: <input type="submit" action="file.php" name="Submit" /> for example.

您需要比submit更多的输入。

And you need to have more inputs than the submit.

根据您的php,您应该有一个例子这在html中:

Acording to your php you should have as example this in the html:

<form action="your_php_file.php" method="post">
 <p>Your first name: <input type="text" name="FName" /></p>
 <p>Your last name: <input type="text" name="LName" /></p>
 <p>Your MI: <input type="text" name="MI" /></p>
 <p><input type="submit" name="Submit"/></p>
</form>

而php标签就像<?php ?> 关闭。

And the php tags are like <?php to open, and ?> to close.

如此:

So like:

<?php
    if(isset($_POST['Submit'])) {
        $FName = $_POST['FName'];
        $MI = $_POST['MI'];
        $LName = $_POST['LName'];
//....
?>

这篇关于点击html提交并运行php代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆