简体   繁体   English

我有一个联系表单,我尝试使用Angularjs将其与PHP邮件连接,并在php文件中获取数据

[英]I have a Contact form, and i'm try to connect it with PHP mail using Angularjs and get get data in php file

 (function() { var app = angular.module('snc', []); app.controller("QueryController", function($http) { this.query = {}; this.sendQuery = function(contact) { contact.querys.push(this.query); this.query = {}; }; }); })(); 
 <form name="queryForm" ng-controller="QueryController as queryCtrl" ng-submit="queryForm.$valid && queryCtrl.sendQuery(contact)" novalidate> <blockquote> <b>Name: {{queryCtrl.query.name}}</b><br/> <b>Mobile: {{queryCtrl.query.mobile}}</b><br/> <b>Eamil: {{queryCtrl.query.email}}</b><br/> <b>Message: {{queryCtrl.query.message}}</b><br/> </blockquote> <div class="form-group"> <label for="Name">Name:<span class="required">*</span></label> <input type="text" ng-model="queryCtrl.query.name" class="form-control" id="name" placeholder="Enter Your Name" required> </div> <div class="form-group"> <label for="Mobile">Mobile:<span class="required">*</span></label> <input type="number" ng-model="queryCtrl.query.mobile" class="form-control" id="mobile" placeholder="Enter Your Mobile Number" required> </div> <div class="form-group"> <label for="email">Email:</label> <input type="email" ng-model="queryCtrl.query.email" class="form-control" id="email" placeholder="Enter Your Email" required> </div> <div class="form-group"> <label for="Message">Message:</label> <textarea type="text" ng-model="queryCtrl.query.message" class="form-control" id="name" placeholder="Enter Your Message" rows="4" required></textarea> </div> <div> reviewForm is {{queryForm.$valid}} </div> <button type="submit" class="btn btn-snc">Submit</button> </form> 

I'm Using ng-app="snc" and Angularjs version 1.6, this is a simple contact form please check it and give me some advice. 我正在使用ng-app =“ snc”和Angularjs 1.6版,这是一个简单的联系表格,请检查并给我一些建议。 i want to send contact form into php page, where i use form data for send email for query and add it into database. 我想将联系表单发送到php页面,在这里我使用表单数据发送电子邮件进行查询并将其添加到数据库中。

Try this code sample code 试试此代码示例代码

 (function() { var app = angular.module('snc', []); app.controller('QueryController', function($scope, $http) { $scope.query = {}; $scope.submit = function() { console.log($scope.query); $http({ method: "POST", url: "", //php url data: { query } }).then(function mySuccess(response) { console.log(response); }, function myError(response) { console.log(response); }); }; }); })(); 
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <form name="fromvalue" ng-app="snc" ng-controller="QueryController"> <b>Name: {{query.name}}</b><br/> <div class="form-group"> <label for="Name">Name:<span class="required">*</span></label> <input type="text" ng-model="query.name" class="form-control" id="name" placeholder="Enter Your Name" required> </div> <div> reviewForm is {{fromvalue.$valid}} </div> <button type="submit" ng-click="submit()" class="btn btn-snc">Submit</button> </form> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我正在使用“帆”:“~1.2.4”。 我正在尝试连接到 MongoDb。 但是当我尝试扬帆起航时,我收到了这个错误: - I'm using “sails”: “~1.2.4”. I'm trying to connect to a MongoDb. But When I try to sails lift I get this error: 我无法让我的 php 邮件程序使用邮政数据发送邮件 - I cant get my php mailer to send a mail using post data 页面更新,当我尝试使用 ajax+php 发送邮件数据时 - Page updates, when I try to send mail-foem data by using ajax+php 如何获得AngularJS http发布到PHP文件? - How do I get an AngularJS http post to a PHP file? 使用php方法file_get_contents,我将整个网页拉到我的网站 - Using the php method file_get_contents I'm pulling an entire webpage to my website 为什么我会被重定向到此联系表单中的 php 文件? - Why am I being redirected to my php file in this contact form? 我怎样才能获得表单数据用javascript验证它并使用php将其发送到数据库 - how can i get form data validate it with javascript and send it to database using php 我正在尝试获取一个动态表单,之后需要使用 PHP 将其数据插入数据库 - I am trying to get a dynamic form after which its data needs to be inserted in the DB using PHP Ajax / PHP联系人表格无法发送邮件 - Ajax/PHP contact form not able to send mail 使用PHP和MySql使用表格数据上传AngularJS文件 - AngularJS file upload with form data using PHP and MySql
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM