简体   繁体   English

注册表错误

[英]Registration form with PHP error

So my probelm is with registration form in PHP. 所以我的问题是使用PHP中的注册表格。 When I set a class for input type, example: <input type="text" name="username" placeholder="Username" **class="textfield"** /> an error occurred 当我为输入类型设置类时,例如: <input type="text" name="username" placeholder="Username" **class="textfield"** />发生错误

Column 'username' cannot be null “用户名”列不能为空

Column 'paswword' cannot be null “ paswword”列不能为空

Column 'email' cannot be null “电子邮件”列不能为空

Index.php source code Index.php源代码

    <?php require_once('Connections/Lidha_me_DB.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "login-1")) {
  $insertSQL = sprintf("INSERT INTO punekerkues (username, password, email) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['username'], "text"),
                       GetSQLValueString($_POST['password'], "text"),
                       GetSQLValueString($_POST['email'], "text"));

  mysql_select_db($database_Lidha_me_DB, $Lidha_me_DB);
  $Result1 = mysql_query($insertSQL, $Lidha_me_DB) or die(mysql_error());

  $insertGoTo = "jobs.html";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_Lidha_me_DB, $Lidha_me_DB);
$query_Register = "SELECT username, password, email FROM punekerkues";
$Register = mysql_query($query_Register, $Lidha_me_DB) or die(mysql_error());
$row_Register = mysql_fetch_assoc($Register);
$totalRows_Register = mysql_num_rows($Register);
?>



<!DOCTYPE html>
<html class="no-js">
<head>

<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/reset.css"/>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<link rel="stylesheet" type="text/css" href="css/jquery.combosex.css"/>


<script type="text/javascript" src="js/jquery.1.7.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.1.7.2.min.js"></script>
<script type="text/javascript" src="js/jquery.combosex.min.js"></script>
<script type="text/javascript" src="js/jquery.easytabs.min.js"></script>
<script type="text/javascript" src="js/jquery.scrollbar.min.js"></script>
<script type="text/javascript" src="js/custom.js"></script>

</head>
<body>

<form id="login-1" action="<?php echo $editFormAction; ?>" method="post" >

    <input type="text" name="username" value="" placeholder="Username"  class="textfield"/>
    <input type="password" name="password" value="" placeholder="Password" class="textfield"/>
    <input type="text" name="email" value="" placeholder="Email" class="textfield"/>

      <input type="submit" value="Register" />
  <input type="hidden" name="MM_insert" value="login-1" />
</form>

</body>
</html>

<?php
mysql_free_result($Register);
?>

And this is the SQL Table Structure for new user registration. 这是用于新用户注册的SQL表结构。 https://docs.google.com/file/d/0B2zaeZ36Ko4uVTNlOFZWVDJHYUE/edit?usp=drivesdk I put the source file in this link: http://www.filedropper.com/test_2 for demo. https://docs.google.com/file/d/0B2zaeZ36Ko4uVTNlOFZWVDJHYUE/edit?usp=drivesdk我将源文件放在此链接中: http : //www.filedropper.com/test_2以进行演示。 Please somebody helps me. 请有人帮我。

这是一个mysql错误,您应该填写所有此列,或者将数据库更改为:

MODIFY COLUMN `username`  varchar(16) DEFAULT

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM