SQLSTATE [HY093]:无效参数号:表单上的参数未定义错误 [英] SQLSTATE[HY093]: INVALID PARAMETER NUMBER: PARAMETER WAS NOT DEFINED error on form

查看:87
本文介绍了SQLSTATE [HY093]:无效参数号:表单上的参数未定义错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在尝试验证我的注册表单,我收到以下错误:



Hi I am trying to validate my register form and i am getting the below error:

SQLSTATE[HY093]: INVALID PARAMETER NUMBER: PARAMETER WAS NOT DEFINED





这是我将名字字段留空的时候。但确实为我提供了错误消息,但也有这个。请参阅下面的代码。我想验证一切,但一次只做一步



我尝试过:





This is when I leave the first name field empty. however does provide me with an error message but also has this. See below the code i have. I want to validate it all but just doing one step at a time

What I have tried:

if(isset($_POST['submit'])){
	
if (empty($_POST['FirstName']))
	{
		
		$error[] = 'Please enter your Forename';
	}

	else 
	{
		$stmt = $conn->prepare('SELECT FirstName FROM Profile WHERE FirstName = :FirstName');
		$stmt->execute(array(':FirstName' => $_POST['FirstName']));
		$row = $stmt->fetch(PDO::FETCH_ASSOC);
	}

	try {

			//insert into database with a prepared statement
			$stmt = $conn->prepare('INSERT INTO Profile (FirstName, Password,  EmailAddress, DueDate) VALUES (:FirstName,  :password, :email, :duedate)');
			$stmt->execute(array(
				':FirstName' =>$_POST['FirstName'],
				$_POST['password'],	
				$_POST['email'],	
				$_POST['dueDate']	
				));

推荐答案

_POST [ 'submit'])){

if(empty(
_POST['submit'])){ if (empty(


_POST ['FirstName']))
{
_POST['FirstName'])) {


error [] ='请输入你的姓名';
}

其他
{
error[] = 'Please enter your Forename'; } else {


这篇关于SQLSTATE [HY093]:无效参数号:表单上的参数未定义错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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