PHP Form与同一页面上的进程? [英] PHP Form with process on same page?

查看:68
本文介绍了PHP Form与同一页面上的进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的页面上创建了一个表单,并从教程的即时消息中得知我必须在第二个页面中处理所有php,是否无法将php保留在同一页面上以及当用户使用时点击提交表格发送?

I've created a form on my page and from the tutorials im following it says I have to have a second page with all the php processing in, is it not possible to keep the php on the same page and when the user hits submit the form is sent?

为什么这在我的流程页面上不起作用?它没有回应任何东西:S

Why isnt this working on my process page? It doesnt echo anything :S

<?php 
$kop = mysql_real_escape_string($_POST['severity']);
$loc = mysql_real_escape_string($_POST['location']};
$summary = mysql_real_escape_string($_POST['summary']);
$name = mysql_real_escape_string($_POST['name']);
$email = mysql_real_escape_string($_POST['email']);

echo $kop;
echo $loc; 
echo $summary; 
echo $name; 
echo $email;
?>

推荐答案

如果按下了提交按钮,则可以签入同一文件. ( http://pastebin.com/8FC1fFaf )

You can check in the same file if the submit button is pressed. (http://pastebin.com/8FC1fFaf)

if (isset($_POST['submit'])) 
{ 
    // Process Form
}
else
{
    // Show Form
}

关于表单检查,您可以保存用户输入,如果他们的数据之一无效,则可以回显旧数据并再次显示表单.

Regarding form checking, you can save the user input, and if one of their data is unvalid you can echo the old data back and show the form again.

正如PeeHaa所说,您需要将该操作留空;)

edit: As PeeHaa stated, you need to leave the action blank though ;)

这篇关于PHP Form与同一页面上的进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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