如何从邮件中抓取数据到班级 [英] How to grab data from post to a class
问题描述
< div ID = login_form >
< form id =registrationmethod =postaction =results.php>
< label for =first_name>名字:< / label>
< input type =textid =first_namename =first_namemaxlength =100tabindex =1/>
< input type =submitid =login_submitname =submitvalue =Submit/ align =right>
< / form>
< / div>
是否可以从表单中获取数据,然后将该数据输出到另一个页面。我现在拥有它的方式只是在表单中回复帖子:
<?php
$ first_name = $ _POST ['first_name'];
$ last_name = $ _POST ['last_name'];
$ email_address = $ _POST ['email_address'];
echo'你好';
echo{$ first_name} {$ last_name};
echo'< br />';
echo'< br />';
echo'我们的电子邮件地址为:';
echo{$ email_address};
echo'';
?>
我不知道如何开始,但我希望发布的数据先去班级。所以如果我创建一个名为registeredUser的类,我将如何从表单中获取这些数据?
你好,我认为你需要一些关于OPP的教程第一个 p
You tube
演示文稿
其他链接
你想要的例子
class RegisterUser {
private $ firstName;
private $ lastName;
private $ emailAddress;
函数__construct(){
$ this-> firstName = isset($ _ POST ['first_name'])? $ _POST ['first_name']:null;
$ this-> lastName = isset($ _ POST ['last_name'])? $ _POST ['last_name']:null;
$ this-> emailAddress = isset($ _ POST ['email_address'])? $ _POST ['email_address']:null;
函数start(){
if(empty($ this-> firstName)|| empty($ this-> lastName)|| empty($ this - > emailAddress)){
抛出新的异常(Empty Post not allowed);
}
else
{
//做一些简单的
回显注册完成;
}
}
}
$ register = new RegisterUser();
if(!empty($ _ POST))
{
$ register-> start();
}
If I have a form such as (not all the code just one field and my input):
<div id="login_form">
<form id="registration" method="post" action="results.php">
<label for="first_name"> First Name: </label>
<input type="text" id="first_name" name="first_name" maxlength="100" tabindex="1" />
<input type="submit" id="login_submit" name="submit" value="Submit"/ align="right">
</form>
</div>
Is it possible to grab the data from the form and then output that data to another page. The way I have it now I am just echoing the post from a form to a page:
<?php
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
echo 'Hello ';
echo "{$first_name} {$last_name}";
echo '<br/>';
echo '<br/>';
echo 'We have your email address as: "';
echo "{$email_address}";
echo '"';
?>
Im not sure how to get started but I would like the data from post to go to a class first. So if I create a class called registeredUser how would I grab that data from my form?
Hello I think you need some tutorials on OPP first
You tube
Presentation
Other Links
Example of what you want
class RegisterUser {
private $firstName;
private $lastName;
private $emailAddress;
function __construct() {
$this->firstName = isset($_POST['first_name']) ? $_POST['first_name'] : null;
$this->lastName = isset($_POST['last_name']) ? $_POST['last_name'] : null;
$this->emailAddress = isset($_POST['email_address']) ? $_POST['email_address'] : null;
}
function start() {
if (empty($this->firstName) || empty($this->lastName) || empty($this->emailAddress)) {
throw new Exception("Empty Post not allowed");
}
else
{
// Do some stuiff
echo " Registration Done";
}
}
}
$register = new RegisterUser();
if(!empty($_POST))
{
$register->start();
}
这篇关于如何从邮件中抓取数据到班级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!