I'm very new with all of this and I was wondering if someone can tell me what I'm doing wrong and maybe point me in the right direction. I have a database all designed with a table that included the fields:
User Name
Email Address
Password
Verify Password.
I'm using Dreamweaver MX and I have made a registration form that I'm trying to implement into my website so that my customers can register to become a member. I can't seem to get this form to enter the data that I'm trying to collect into the database fields. I keep getting an error: column "User Name" cannot be "NULL". Does anyone have any ideas for me. I would absolutely appreciate it greatly. Below is the copy of my code for the registration form:
<?php require_once('file:///E|/Gspot%20Website/Connections/GspotMembers.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "Register")) {
$insertSQL = sprintf("INSERT INTO Members (User Name) VALUES (%s)",
GetSQLValueString($HTTP_POST_VARS['User Name'], "text"));
mysql_select_db($database_GspotMembers, $GspotMembers);
$Result1 = mysql_query($insertSQL, $GspotMembers) or die(mysql_error());
$insertGoTo = "file:///E|/Gspot Website/Successfulpayment.htm";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Registration</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<p>Username:
<input name="UserName" type="text" id="UserName">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
<input type="hidden" name="MM_insert" value="Register">
</form>
</body>
</html>