Page 2 of 2

Posted: Fri Jul 21, 2006 4:03 pm
by Assured99
Here the Issue in its simpleist form

Code: Select all

Unknown column 'anything the registrar inserts into this text box' in 'field list'


WHYYYYYYYYYY!!!!!! :x

Posted: Fri Jul 21, 2006 4:08 pm
by Luke
post ALL of your code please

Posted: Fri Jul 21, 2006 4:16 pm
by Assured99
Here is the register.html

Code: Select all

<HTML>
<HEAD>
<TITLE>Registration</TITLE>

<script Language="JavaScript">
<!--
function Form1_Validator(theForm)
{
  	if (theForm.firstname.value == "")
  {
    alert("Please enter a value for the \"firstname\" field.");
    theForm.firstname.focus();
    return (false);
  }
  	if (theForm.lastname.value == "")
  {
    alert("Please enter a value for the \"lastname\" field.");
    theForm.firstname.focus();
    return (false);
  }
  	if (theForm.company.value == "")
  {
    alert("Please enter a value for the \"company\" field if you are a patient please enter N/A.");
    theForm.firstname.focus();
    return (false);
  }
	if (theForm.username.value == "")
  {
    alert("Please enter a value for the \"username\" field.");
    theForm.firstname.focus();
    return (false);
  }
	if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"email\" field.");
    theForm.email.focus();
    return (false);
  }	
  	if (theForm.password.value == "")
  {
    alert("Please enter a value for the \"password\" field.");
    theForm.email.focus();
    return (false);
  }
	if (theForm.password.value != theForm.confirm.value)
	{
		alert("The two passwords are not the same.");
		theForm.confirm.focus();
		return (false);
	}
}

//--></script>
<style type="text/css">
<!--
.style2 {
	font-size: 24px;
	font-weight: bold;
}
.style4 {font-size: 14px}
-->
</style>
</head>

<BODY>
<div align="left"><img src="../../Images/headers and logos/logosm.jpg" alt="AMS" width="73" height="96" longdesc="http://www.assuredmedical.com/Images/headers and logos/logosm.jpg"><span class="style2">Welcome to Assured Medical Supply's Online Registration Form
  
</span></div>
<FORM METHOD="POST" ACTION="register.php" onSubmit="return Form1_Validator(this)" name="Form1">

<P style="margin-top: 0; margin-bottom: 0"><font face="Tahoma">
<span style="font-size: 14px"><strong style="font-weight: 400">First Name:</strong></span><font size="2"><BR></font><font face="Tahoma" size="1">

<INPUT NAME="firstname" SIZE=25 MAXLENGTH=50></font></font></p>
<strong style="font-weight: 400"><span class="style4">Last Name</span><font size="2">:</font></strong><font size="2"><BR>
</font><font face="Tahoma" size="1">
<INPUT NAME="lastname" SIZE=25 MAXLENGTH=50><br>

</font><P style="margin-top: 0; margin-bottom: 0;"><font face="Tahoma">
<strong style="font-weight: 400"><font size="2">Company:</font></strong><font size="2"><BR>
</font><font face="Tahoma" size="1">
<INPUT NAME="company" SIZE=25 MAXLENGTH=50><br>
</font><span class="style4">Username:</span></font>
<br>
  <INPUT NAME="username" SIZE=25 MAXLENGTH=50>
  <br>
  <font face="Tahoma"><strong style="font-weight: 400">Password:</strong><font size="2"><BR>
  </font><font face="Tahoma" size="1">
<INPUT TYPE="password" NAME="password" SIZE=25 MAXLENGTH=25>
<br>

  </font>Confirm Password:<font face="Tahoma" size="1"><br>
  <INPUT TYPE="password" NAME="confirm" SIZE=25 MAXLENGTH=25>
  </font></font>
<P style="margin-top: 0"><span style="font-size: 14px"><strong style="font-weight: 400">
<font face="Tahoma">E-Mail Address</font></strong><font face="Tahoma"><strong style="font-weight: 400">:</strong></font></span><font face="Tahoma"><font size="2"><BR>
</font><font face="Tahoma" size="1">
<INPUT TYPE="text" NAME="email" SIZE=25 MAXLENGTH=100></font></font><br>
Requested Access Level:<br>
<label>
<select name="access">
    <option>Access Level Request</option>
    <option>Employee</option>
    <option>Patient</option>
    <option>Referral</option>
  </select>
  </label>
</p>
<P style="margin-top: 0; margin-bottom: 0">
<INPUT TYPE="submit" NAME="submit" VALUE="Submit" style="font-family: Tahoma"></p>
</FORM>
<p>All fields are required. If your are a patient please enter N/A for company </p>
</BODY>
</HTML>
Here is the Register.PHP

Code: Select all

<?php

//prevents caching
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter();

session_start();

//require the config file
require ("config.php");
require ("functions.php");

//checks password length
if (password_check($min_pass, $max_pass, $_POST[password]) == "no")
{
?>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="refresh" content="0; url=javascript:history.go(-1)">
<title>Registration</title>
<script language="JavaScript">
<!--
function FP_popUpMsg(msg) {//v1.0
 alert(msg);
}
// -->
</script>
</head>

<body onLoad="FP_popUpMsg('Your password must be between <? echo $min_pass; ?> & <? echo $max_pass; ?> characters.')">

</body>

</html>
<?
exit;
}

//make the connection to the database
$connection = @mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error());
$db = @mysql_select_db($db_name,$connection)or die(mysql_error());

//make query to database
$sql ="SELECT * FROM $table_name WHERE username= '$_POST[username]'";
$result = @mysql_query($sql,$connection) or die(mysql_error());

//get the number of rows in the result set
$num = mysql_num_rows($result);

//checks it see if that username already exists
if ($num != 0){

echo "<P>Sorry, that username already exists.</P>";
echo "<P><a href=\"#\" onClick=\"history.go(-1)\">Try Another Username.</a></p>";
exit;

}
else
{
$sql = "INSERT INTO $table_name VALUES ('$_POST[firstname]', '$_POST[lastname]', $_POST[company], '$_POST[username]', password('$_POST[password]'), 'Users', '', '', '$pchange', '$_POST[email]', '$_POST[access]', '$default_url', '$verify', '')";

$result = @mysql_query($sql,$connection) or die(mysql_error());
}

//checks to see if the user needs to verify their email address before accessing the site
if ($verify == "0")
{
	$mailheaders = "From: www$domain\n";
	$mailheaders .= "Your account has been created.\n";
	$mailheaders .= "Please activate your account now by visiting this page:\n";
	$mailheaders .= "$base_dir/activate.html\n";


	$to = "$_POST[email]";
	$subject = "Please activate your account";

mail($to, $subject, $mailheaders, "From: No Reply <$adminemail>\n");

}else{
	header('Location:login.html');
}



?>

<HTML>
<HEAD>
<TITLE>Add a User</TITLE>
</HEAD>
<BODY>
<H1>Please check your email to activate your account.</H1>
</BODY>
</HTML>

Posted: Fri Jul 21, 2006 4:33 pm
by Weirdan
put $_POST[company] in the single quotes in your query

Posted: Fri Jul 21, 2006 4:38 pm
by Assured99
Weirdan wrote:put $_POST[company] in the single quotes in your query

Weirdan your the man that is exactly what the problem was the whole time.

I could kick my own arse for this one

Thanks Again! :roll: :P

Posted: Fri Jul 21, 2006 4:39 pm
by Luke
single quotes make whatever you are sending literal. So if you did '$var' it would literally put $var, not the value of var, so take your $_POST['bla'] out of the single quotes... change all

Code: Select all

'$_POST[var]'
to

Code: Select all

$_POST['var']
EDIT: OK maybe I'm wrong lol