Jump to content
Larry Ullman's Book Forums

Recommended Posts


	# submit_docs.php
	# insert submitted documents of ESA
	$page_title = 'Submit ESA Documents';
	include ('includes/header.html');
	//Page header:
	echo '<h1>Submit ESA Documents</h1>';
	require ('includes/mysqli_connect.php'); //connect to db
	//check form:
		$errors[] = array();
		if (empty($_POST['municipality'])) {
			$errors[] = 'You forgot to select municipality';
		} else {
			$muni = mysqli_real_escape_string($dbc, trim($_POST['municipality']));
		if (empty($_POST['remarks'])) {
			$errors[] = 'You forgot to enter remarks';						
		} else {
			$rema = mysqli_real_escape_string($dbc, trim($_POST['remarks']));
		if (isset($_POST['submitted'])) {
			$submitted = implode(',', $_POST['submitted']);
			$subm = mysqli_real_escape_string($dbc, trim($submitted));
		//if no errors:
		if (empty($errors)) {
			//register data of submitted docs
			//make query:
			$q = "INSERT INTO subdocs (lgu_id, sub_docs, remarks, registration_date)
			VALUES ('$id', '$subm', '$rema', NOW())";
			$r = @mysqli_query($dbc, $q); //run the query
			if ($r) { //if it ran ok
				//print message:
				echo '<h1>Thank You for submitting ESA Documents</h1>';			
			} else {
				//public message:
				echo '<h1>System Error</h1>';
				//debugging message:
				echo '<p>' . mysqli_error($dbc) . '<br /><br />Query:' . $q . '</p>';
			} //end of if 
			mysqli_close($dbc); //close the database			
		} else { //report errors
			echo '<h1>ERROR</h1>
			<p class="error">The following errors occurred';
				foreach ($errors as $msg) {
					echo " - $msg<br />\n";									
			echo '<p>Please Try Again</p>';	

	//make the query:
	$q = "SELECT lgu_id, municipality FROM lgu ORDER BY municipality ASC";
	$r = @mysqli_query ($dbc, $q); //run the query
	if ($r) { //if OK
		//fetch and print record
		echo '<form action="submit_docs.php" method="post">';
		echo '<p><b>Municipality:</b> <select name="municipality">';
			while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
				echo "<option value=\"$row[municipality]\">$row[municipality]</option>\n";
		echo '</select></p>';
		echo '<p>Submitted Documents:</p>
		<p><input type="checkbox" name="submitted[]" value="Project Proposal">Project Proposal
		<input type="checkbox" name="submitted[]" value="MOA">Memorandum Of Agreement
		<input type="checkbox" name="submitted[]" value="Certificate of Eligibility">Certificate of Eligibility
		<input type="checkbox" name="submitted[]" value="Masterlist">Masterlist
		<input type="checkbox" name="submitted[]" value="Rehabilitaion Plan">Rehabilitation Plan
		echo '<p>Remarks:</p>
		<p><textarea rows="12" cols="50" name="remarks"></textarea></p>
		<p><input type="submit" name="submit" value="register" /></p>
		<input type="hidden" name="lgu_id" value="' . $row['lgu_id'] . '"';
		echo '</form>';



the error is array

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...