I am having a registration form which i am trying to make using php.
I am getting the following errors. ..
Notice: Undefined index: chkOption2 in c:\winntnew\easyphp1-7\www\iwpsd\insert.php on line 18
Notice: Undefined index: chkOption3 in c:\winntnew\easyphp1-7\www\iwpsd\insert.php on line 19
Warning: mysql_connect(): Access denied for user: 'iwpsd2005@localhost' (Using password: YES) in c:\winntnew\easyphp1-7\www\iwpsd\insert.php on line 23
Warning: mysql_select_db(): Access denied for user: 'ODBC@localhost' (Using password: NO) in c:\winntnew\easyphp1-7\www\iwpsd\insert.php on line 24
Warning: mysql_select_db(): A link to the server could not be established in c:\winntnew\easyphp1-7\www\iwpsd\insert.php on line 24
Unable to select database
Here EasyPHP is the software through which PHP, Apache, MYSQL is installed on my computer.
Please help me in finding out the problem. the code for the forms are as follows.
===========================
REGISTRATIONFORM.HTM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Information Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/styles.css" rel="stylesheet">
<SCRIPT LANGUAGE="JavaScript">
function checkEmail(myForm) {
if (/\w+([.-]?\w+)@\w+([.-]?\w+)(.\w{2,3})+$/.test(myForm.txtEmail.value))
{
return (true)
}
return (false)
}
function checkbox_checker(form)
{
var counter=0;
if (form.chkOption1.checked)
{
counter=counter+1;
}
if (form.chkOption2.checked)
{
counter=counter+1;
}
if (form.chkOption3.checked)
{
counter=counter+1;
}
if(counter>0)
{
return true;
}
else
{
//alert("Please check at least one checkbox..");
return false;
}
}
function validateName(form)
{
var validname=form.txtName.value;
if(validname=="")
{
return false;
}
else
{
return true;
}
}
function validateAddress(form)
{
var validadd=form.txtAddress.value;
if(validadd=="")
{
return false;
}
else
{
return true;
}
}
function validateForm()
{
errMsg = '';
var msg='';
isValid = true;
if (!validateName(document.form))
{ isValid = false; errMsg = errMsg + '<font color="#ff3366"><b><li>Please enter Name.</li></b></font>'; }
if (!validateAddress(document.form))
{ isValid = false; errMsg = errMsg + '<BR><font color="#ff3366"><b><li>Please enter Address.</li></b></font>'; }
if (!checkEmail(document.form))
{ isValid = false; errMsg = errMsg + '<BR><font color="#ff3366"><b><li>Please fill in a correct E-mail address(email@domain.com).</li></b></font>'; }
if (!checkbox_checker(document.form))
{ isValid = false; errMsg = errMsg + '<BR><font color="#ff3366"><b><li>Please check at least one Checkbox.</li></b></font>'; }
if (isValid) { return isValid; }
document.getElementById('err').innerHTML= errMsg;
return isValid;
}
</script>
</head>
<body>
<form id="form" name="form" method ="post" onsubmit="return validateForm();" action="insert.php">
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr>
<th colspan="6" align=center><font color="#000099"><b>Information Form, XIII, IWPSD -2005</b></font></th>
<td></td>
</tr>
<tr>
<td colspan="6" align= "center"><font color="#ff3366">(Please Fill in the Complete Details)</font></td>
</tr>
<tr><td><br><br></td></tr>
<tr>
<td><font color="#000099">Title:</font></td>
<td ><select name="ddlTitle">
<option value="Prof." >Prof.</option>
<option value="Mr." selected="true">Mr.</option>
<option value="Ms./Mrs.">Ms./Mrs.</option>
<option value="Dr.">Dr.</option>
</select></td>
<td><font color="#ff3366"><b>*</b></font><font color="#000099">Name:</font></td>
<td><input type=text maxlength="50" name="txtName" ></td>
</tr>
<tr><td><br></td></tr>
<tr>
<td><font color="#ff3366"><b>*</b></font><font color="#000099">Postal Address:</font></td>
<td><textarea rows="4" name="txtAddress"></textarea> </td>
</tr>
<tr><td><br></td></tr>
<tr>
<td><font color="#000099">Phone:</font></td>
<td><input type="text" maxlength="15" name="txtPhone"></td>
<td><font color="#000099">Fax:</font></td>
<td><input type="text" maxlength="15" name="txtFax"></td>
<td><font color="#ff3366"><b>*</b></font><font color="#000099">E-Mail:</font></td>
<td><input type="text" maxlength ="25" name="txtEmail"></td>
</tr>
<tr><td><br></td></tr>
<tr>
<td colspan="6"><font color="#ff3366"><b>*</b></font><font color="#ff3366">I wish to (Check one or more boxes below)</td>
</tr>
<tr>
<td colspan="2"><input type="checkbox" name="chkOption1" value="1"><font color="#000099">Attend the workshop</font></td>
<td colspan="2"><input type="checkbox" name ="chkOption2" value="2"><font color="#000099">Present Paper(s)</font></td>
<td colspan="2"><input type="checkbox" name ="chkOption3" value="3"><font color="#000099">Receive more information</font></td>
</tr>
<tr><td><br></td></tr>
<tr>
<td><input type="submit" name="btnSubmit" value="Submit" >
<input type="reset" name="btnReset" value="Reset"></td>
</tr>
<tr>
<td colspan="6"><hr></td>
</tr>
<tr>
<td colspan="6"><font color="#0936F8"><b>Note: Fields marked <font color="#ff3366">*</font> must at least be filled</b></font> </td>
</tr>
</table>
<div id="err" align=justify runat=server ></div>
</form>
</body>
INSERT.PHP
<html>
<head>
</head>
<body>
<?
$username="iwpsd2005";
$password="iwpsd2005";
$database="main";
$title=$POST['ddlTitle'];
$name=$POST['txtName'];
$address=$POST['txtAddress'];
$phone=$POST['txtPhone'];
$fax=$POST['txtFax'];
$email=$POST['txtEmail'];
$chk1=$POST['chkOption1'];
$chk2=$POST['chkOption2'];
$chk3=$_POST['chkOption3'];
mysql_connect("localhost",$username,$password);
mysql_select_db($database) or die( "Unable to select database");
$query= "INSERT DELAYED INTO IWPSD_PERSONAL('',title,name,address,phone,fax,email) VALUES ('$title','$name','$address','$phone','$fax','$email')";
mysql_query($query);
$NextID= mysql_insert_id();
if (isset($chk1))
{
$query1 = "INSERT DELAYED INTO IWPSD_OPTION VALUES ('$NextID','$chk1')";
mysql_query($query1);
}
if (isset($chk2))
{
$query2 = "INSERT DELAYED INTO IWPSD_OPTION VALUES ('$NextID','$chk2')";
mysql_query($query2);
}
if (isset($chk3))
{
$query3 = "INSERT DELAYED INTO IWPSD_OPTION VALUES ('$NextID','$chk3')";
mysql_query($query3);
}
mysql_close();
echo "<SCRIPT LANGUAGE=\"JavaScript\">
alert('Thanks for submitting your information');
window.location.href='home.htm';
</SCRIPT>";
?>
</body>
</html>