简体   繁体   中英

Registration form with PHP error

So my probelm is with registration form in PHP. When I set a class for input type, example: <input type="text" name="username" placeholder="Username" **class="textfield"** /> an error occurred

Column 'username' cannot be null

Column 'paswword' cannot be null

Column 'email' cannot be null

Index.php source code

    <?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. 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. Please somebody helps me.

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

MODIFY COLUMN `username`  varchar(16) DEFAULT

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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