这是我的HTML。
<div class="col-md-8">
<form (submit)="onSubmit()" method="POST">
<input type="text" class="form-control mb-2" name="names" [(ngModel)]="profileForm.name" placeholder="Username" required autofocus>
<input type="text" class="form-control mb-2" name="email" [(ngModel)]="profileForm.email" placeholder="Email" required autofocus>
<input type="password" class="form-control mb-2" name="password" [(ngModel)]="profileForm.password" placeholder="Password" required>
<input type="password" class="form-control mb-2" name="repassword" [(ngModel)]="profileForm.repassword" placeholder="Re-Password" required>
<button class="btn btn-lg btn-primary btn-block mb-1" type="submit">Sign in</button>
<label class="checkbox float-left">
<input type="checkbox" value="remember-me">
Remember me
</label>
<a href="#" class="float-right">Need help?</a>
</form>
这是ts
文件:
onSubmit() {
console.warn(this.profileForm);
this.http.post('./script.php', this.profileForm).subscribe(function(data) {
});
}
答案 0 :(得分:1)
您必须将php文件放置在服务器上,以运行在本地PC上的xampp服务器为例,将文件放置在htdocs文件夹中,将数据库连接到该php文件中,然后启动xampp服务器,这样您的链接将为{ {1}}。
将此链接作为
http://localhost/script.php