I don't know why I get this. I am not handling these variables in this web page so I'm not sure why it's being brought up to me.
Ok script added. I think the problem is my function files already run the lines needed to establish the connections so each include is causing it to happen again. Any way to simplify? thanks
Notice: Constant DB_HOST already defined in C:\xampp\htdocs\cw1\db_config.php on line 2
Notice: Constant DB_NAME already defined in C:\xampp\htdocs\cw1\db_config.php on line 3
Notice: Constant DB_USER already defined in C:\xampp\htdocs\cw1\db_config.php on line 4
Notice: Constant DB_PASSWORD already defined in C:\xampp\htdocs\cw1\db_config.php on line 5
Notice: Constant DB_HOST already defined in C:\xampp\htdocs\cw1\db_config.php on line 2
Notice: Constant DB_NAME already defined in C:\xampp\htdocs\cw1\db_config.php on line 3
Notice: Constant DB_USER already defined in C:\xampp\htdocs\cw1\db_config.php on line 4
Notice: Constant DB_PASSWORD already defined in C:\xampp\htdocs\cw1\db_config.php on line 5
?php include 'mefunc.php'; include 'memberfunc.php'; include 'eventfunc.php'; //include the lot they are all needed!
?php include 'mefunc.php'; include 'memberfunc.php'; include 'eventfunc.php'; //include the lot they are all needed!
$db1 = new dbme();
$db1->openDB();
$sql="select mid from member";
$result=$db1->getResult($sql);// get the ids from the tables for the select
$sql1="select ename from event";
$result1=$db1->getResult($sql1);// get the ids from the tables for the select
if (!$_POST) //page loads for the first time
{
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return validateForm( );">
Select Member ID: <select name="mid">
<?php
while($row = mysql_fetch_assoc($result))
echo "<option value='{$row['mid']}'>{$row['mid']} </option>";
?>
</select>
<br />
Select Event name : <select name="ename">
<?php
while($row = mysql_fetch_assoc($result1))
echo "<option value='{$row['ename']}'>{$row['ename']} </option>";
?>
</select>
<br />
<script language="javascript">
function validateField( fld ) { //validation of all forms. The field will change colour if wrong.
var field = document.getElementById( fld );
if( !field ) return true;
var error = field.value != '';
if( error ) {
field.style.backgroundColor = 'White';
} else {
field.style.backgroundColor = 'Orange';
}
return error;
}
function validateForm( ) {
var cont = true;
if( !validateField( 'total' ) ) cont = false;
if( !validateField( 'comments' ) ) cont = false;
return cont;
}
</script>
Enter lifter total:<input type="text" name="total" id="total" /><br />
Enter comment:<input type="text" name="comments" id="comments"/><br />
<input type="submit" value="Save" />
</form>
<?php
}
else//post it into database
{
//$mid = $_POST['mid'];//??
$mid = $_POST['mid'];
$total = $_POST['total'];
$comments = $_POST['comments'];
$ename = $_POST['ename'];
$db1 = new dbme();
$db1->openDB();
$numofrows = $db1->insert_me($mid, $total, $comments, $ename);
echo "Success. Number of rows affected:
<strong>{$numofrows}<strong>";
$db1->closeDB();
}
$db1 = new dbmember();//show members to see
$db1->openDB();
$sql="SELECT * from member";
$result=$db1->getResult($sql);
echo "<table border='1'>";
echo "<tr><th>Member ID</th><th>Name</th>";
while($row = mysql_fetch_assoc($result))
{
echo "<tr>";
echo "<td>{$row['mid']}</td><td>{$row['name']}</td>";
echo "</tr>";
}
echo "</table>";
$db1->closeDB();
$db1 = new dbevent();//now show events to see too
$db1->openDB();
$sql="SELECT * from event";
$result=$db1->getResult($sql);
echo "<table border='1'>";
echo "<tr><th>Event ID</th><th>Event Name</th><th>Date</th>";
while($row = mysql_fetch_assoc($result))
{
echo "<tr>";
echo "<td>{$row['eid']}</td><td>{$row['ename']}</td>";
echo "<td>{$row['date']}</td>";
echo "</tr>";
}
echo "</table>";
$db1->closeDB();
?>