error message is:
Notice: Undefined variable: name in C:\xampp\htdocs\pgschool\pgindex.php on line 38
Notice: Undefined variable: regno in C:\xampp\htdocs\pgschool\pgindex.php on line 38
Notice: Undefined variable: faculty in C:\xampp\htdocs\pgschool\pgindex.php on line 38.......
========================================
here is the code
=======================================================
Code: Select all
<?php include("includes/functions.php");?>
<html>
<head>
<link rel = "stylesheet" href = "includes/pgindex.css" type = "text/css" media = "screen">
<head>
<?php $connection = mysql_connect("localhost", "root", "");
if (!$connection){
die("Database connection failed to connect: " .mysql_error());
}
$db_select = mysql_select_db("pgschool", $connection);
if (!$db_select){
die("database selection failed: " . mysql_error());
}
?>
<?php
if (isset($_POST['submit'])){
$id = mysql_prep($_GET['id']);
$name = mysql_prep($_POST['name']);
$regno = mysql_prep($_POST['regno']);
$faculty = mysql_prep($_POST['faculty']);
$dept = mysql_prep($_POST['dept']);
$deg_in_view = mysql_prep($_POST['deg_in_view']);
$initial_reg_date = mysql_prep($_POST['initial_reg_date']);
$payment_id = mysql_prep($_POST['payment_id']);
$session = mysql_prep($_POST['session']);
$amount_due = mysql_prep($_POST['amount_due']);
$amount_paid = mysql_prep($_POST['amount_paid']);
$receipt_no = mysql_prep($_POST['receipt_no']);
$balance = mysql_prep($_POST['balance']);
$officer_remark = mysql_prep($_POST['officer_remark']);
$date = mysql_prep($_POST['date']);
}
$query = "INSERT INTO payhistory (name, regno, faculty, dept, deg_in_view,
initial_reg_date, payment_id, session, amount_due, amount_paid, receipt_no, balance, officer_remark, date
) VALUES ('$name','$regno','$faculty','$dept','$deg_in_view','$initial_reg_date',
$payment_id,'$session', $amount_due, $amount_paid,$receipt_no,$balance,
'$officer_remark',$date)";
$result = mysql_query($query, $connection);
if ($result) {
//success!
//redirect_to("home.php");
echo "<p> Form has been succesfully submitted. </p>";
}else{
//Display error msg
echo "<p> Form submission failed..</p>";
echo "<p>". mysql_error() ."</p>";
}
?>
<body>
<div>
<h3>PG Payment History form</h3>
</div>
<form action = "pgindex.php" name = "" method = "post">
<p>NAME: <input type = "text" id = "" name = "name" /></p>
<p>REG NO: <input type = "text" id = "" name = "reg_no" /></p>
<p>FACULTY: <select name="faculty" >
<?php $faculties = mysql_query("SELECT * FROM faculties", $connection);
if (!$faculties){
die ("database query failed: ". mysql_error());
}?>
<?php while ($faculty = mysql_fetch_array($faculties)) { ?>
<option><?php echo $faculty["fac_name"]; ?></option>
<?php } ?>
</select></p>
<p>DEPT:
<select name = "dept" >
<?php $depts = mysql_query("SELECT * FROM departments ", $connection);
if (!$depts){
echo ("database query failed: ". mysql_error());
}?>
<?php while ($dept = mysql_fetch_array($depts)) { ?>
<option><?php echo $dept["dept_name"]; ?></option>
<?php } ?>
</select></p>
<p>DEGREE IN VIEW
<input type = "text" id = "" name = "deg_in_view" /></p>
<p>DATE OF FIRST REG: <input type = "text" id = "" name = "initial_reg_date" /></p>
<table id = "details">
<tr>
<th>S/N</th>
<th>SESSION</th>
<th>AMOUNT DUE</th>
<th>AMOUNT PAID</th>
<th>RECEIPT NO.</th>
<th>BALANCE</th>
</tr>
<tr>
<td><input type = "text" id = "" name = "payment_id" /></td>
<td><input type = "text" id = "" name = "session" /></td>
<td><input type = "text" id = "" name = "amount_due" /></td>
<td><input type = "text" id = "" name = "amount_paid" /></td>
<td><input type = "text" id = "" name = "receipt_no" /></td>
<td><input type = "text" id = "" name = "balance" /></td>
</tr>
</table> <br/>
<p>LIASON OFFICER REMARK: <input type = "text" id = "" name = "officer_remark" /></p>
<p>DATE:
<input type = "text" name = "date" value ="<?php echo date ("y/m/d"). '<br/>'; ?>" /></p>
<input type = "submit" id = "" name = "submit" value = "submit" />
</form>
<body>
</html>
<?php mysql_close($connection);?>