vignesh krishnamurthy Ответов: 0

Как вставить данные в базу данных oracle с помощью PHP


привет...
я пытаюсь вставить данные в базу данных oracle с помощью php, но они не вставляются в базу данных.
он тоже не показывает никаких ошибок.
Когда я нажимаю на кнопку Отправить, форма становится пустой.

пожалуйста, помогите ребятам.

Что я уже пробовал:

элемент формы.

<form action="rbi_data_entry_insert.php" method="POST">

<fieldset class="rbi_circular"><br/>
<label for="Compliance Ref NO" hidden="">Compliance Referance Number</label>
<input type="textbox" placeholder="Enter Compliance Referance Number" name="Compliance Ref NO" value="REF/" id="Compliance Ref NO" hidden=""><br/><br/>

<label for="CS Circular Ref number">CS Circular Ref number</label>
<input type="textbox" placeholder="Enter CS Circular Ref number" name="CS Circular Ref number" id="CS Circular Ref number" required=""><br/><br/>

<label for="RBI Ref Number">RBI Referance Number</label>
<input type="textbox" placeholder="RBI Ref Number" name="RBI Ref Number" id="RBI Ref Number" required=""><br/><br/>

<label for="Entry Date">Entry Date</label>
<input type="date" name="Entry Date" required=""><br/><br/>

<label for="Subject">Subject</label>
<input type="textbox" placeholder="Enter Subject" name="Subject" id="Subject" required=""><br/><br/>

<label for="Department Name">Department Name</label>
<select name="Department Name" required="">
<option value="Department Name">Department Name</option>
<option value="AFMD">ACCOUNTS AND FUND MANAGEMENT DEPARTMENT</option>
<option value="ABG">AGRICULTURAL BANKING GROUP</option>
<option value="BIAC">BIAC</option>
<option value="CS">CHAIRMANS SECRETARIATE</option>
<option value="CCBG">COMMERCIAL AND CORPORATE BANKING GROUP</option>
<option value="CBG">COMMERCIAL BANKING GROUP</option>
<option value="COMCL">COMMPLIANCE DEPARTMENT</option>
<option value="CIG">CORPORATE AND INSTITUTIONAL GROUP</option>
<option value="CRAUD">CREDIT AUDIT</option>
<option value="CMG">CREDIT MONITORING GROUP</option>
<option value="FCD">FINANCE AND CONTROL DEPARTMENT</option>
<option value="HRD">HUMAN RESOURCE DEPARTMENT</option>
<option value="ISG">INFORMATION SECURITY GROUP</option>
<option value="IAD">INSPECTION AND AUDIT DEPARTMENT</option>
<option value="IBG">INTERNATIONAL BANKING GROUP</option>
<option value="IRC">INVESTORS RELATIONS CELL</option>
<option value="KYC/AML">KYC/AML CELL</option>
<option value="LEGAL">LEGAL DEPARTMENT</option>
<option value="MIS">MANAGEMENT INFORMATION SYSTEM CELL</option>
<option value="OD">OPERATIONS DEPARTMENT</option>
<option value="PBG">PERSONAL BANKING GROUP</option>
<option value="PRCCC">PR AND CORPORATE COMMUNICATIONS CELL</option>
<option value="RMCD">RISK MANAGEMENT AND COMPLIANCE DEPARTMENT</option>
<option value="RMD">RISK MANAGEMENT DEPARTMENT</option>
<option value="SHARES">SHARES</option>
<option value="STY">STATIONERY SECTION</option>
<option value="SAMD">STRESSED ASSETS MANAGEMENT DEPARTMENT</option>
<option value="TAX CELL">TAX CELL</option>
<option value="TECHNOLOGY DEPARTMENT">TECHNOLOGY DEPARTMENT</option>
<option value="TFMD">TREASURY AND FUNDS MANAGEMENT DEPARTMENT</option>
<option value="TD">TREASURY DEPARTMENT</option>
</select><br/><br/>

<label for="RBI Due Date">RBI Due Date</label>
<input type="date" name="RBI Due Date" required=""><br/><br/>

<label for="RBI End Date">RBI End Date</label>
<input type="date" name="RBI End Date" required=""><br/><br/>

<label for="Action to be taken">Action to be taken</label>
<textarea name="Action to be taken" ROWS="5" COLS="50" id="Action to be taken" required=""> </textarea><br/><br/>

<label for="Attachment">Attachment Required</label>
Yes <input type="radio" id="chk" name="Attachment" value="Yes" checked="checked" required=""> 
No <input type="radio" name="Attachment" value="No" required=""><br/><br/>

<label for="Upload" id="upload">Upload your Attachment:</label>
<form id="upload_form" method="POST" enctype="multipart/form-data">
<input type="file" id="file" name="file">
<button type="upload" id="btn" value="Upload" name="upload" onclick="">Upload</button>
</form>
<br><br>
<center>
<input type="submit" name="submit" value="SUBMIT"/>   
<input type="reset" name="reset" value="RESET" onclick="reload()"><br/><br/>
</center>
</fieldset>
</form>


кодирование на стороне внутреннего сервера.

<?php

if (isset($_POST['submit'])) 
{
	include 'includes/db_connection.php';
		if (!$conn) 
		{
			$e = oci_error();

			//For oci_connect errors pass to handle

			echo "Database connection failed. <br>";

			echo htmlentities($e['message']);
		}
		else
			{

				//Getting user provided database
				$cs_ref_no = $_POST['CS Circular Ref number'];
				$rbi_ref_no = $_POST['RBI Ref Number'];
				$entry_date = $_POST['Entry Date'];
				$sub = $_POST['Subject'];
				$dept_name = $_POST['Department Name'];
				$rbi_due_date = $_POST['RBI Due Date'];
				$rbi_end_date = $_POST['RBI End Date'];
				$action = $_POST['Action to be taken'];
				$attach = $_POST['Attachment'];

		/*	//checking for error handlers
				if (empty($cs_ref_no) || empty($rbi_ref_no) || empty($entry_date) || empty($sub) || empty($dept_name) || empty($rbi_due_date) || empty($rbi_end_date) || empty($action) || empty($attach)) 
				{
					header('location: data_entry.php?fields=empty');
					exit();
				}
				else
				{
			*/	
					//preparing sql statement to insert data into the database
				/*	$sql = 'insert into rbi_data_entry (COMP_REF_NO,CS_REF_NUMBER,RBI_REF_NUMBER,ENTRY_DATE,SUBJECT,DEPARTMENT_NAME,RBI_DUE_DATE, RBI_END_DATE,ACTION_TO_BE_TAKEN,ATTACHMENT) values(data_entry_insert.nextval, :cs, :rbi, :entry, ":sub", ":dept", :rbi_due, :rbi_end, ":action", ":attach")';

				*/	//To avoid sql injection we have to check the data for any malecious content in the user provided information
					$compile = oci_parse($conn, 'insert into rbi_data_entry (COMP_REF_NO,CS_REF_NUMBER,RBI_REF_NUMBER,ENTRY_DATE,SUBJECT,DEPARTMENT_NAME,RBI_DUE_DATE, RBI_END_DATE,ACTION_TO_BE_TAKEN,ATTACHMENT)'. 'values(data_entry_insert.nextval, :cs, :rbi, :entry, :sub, :dept, :rbi_due, :rbi_end, :action, :attach)');

					//providing the actual value to the placholder's after checking the user provided data
					oci_bind_by_name($compile, ":cs", $cs_ref_no);
					oci_bind_by_name($compile, ":rbi", $rbi_ref_no);
					oci_bind_by_name($compile, ":entry", $entry_date);
					oci_bind_by_name($compile, ":sub", $sub);
					oci_bind_by_name($compile, ":dept", $dept_name);
					oci_bind_by_name($compile, ":rbi_due", $rbi_due_date);
					oci_bind_by_name($compile, ":rbi_end", $rbi_end_date);
					oci_bind_by_name($compile, ":action", $action);
					oci_bind_by_name($compile, ":attach", $attach);

					//executing the statement
					$result = oci_execute($compile, OCI_DEFAULT);

					//Checking weather the data has been inserted or not
					$row = oci_fetch_array($compile);

						if($result > 0)
						{
							echo '<h1 align="center" color="#008000">DATA INSERTED SUCCESSFULLY</h1>';
							oci_commit($conn);
							oci_free_statement($compile);
							oci_close($conn);
							header('location: data_entry.php');
							exit();

						}
						else
						{
							echo '<h1 align="center" color="red">Something went wrong please try again</h1>';
							oci_rollback($conn);
							oci_free_statement($compile);
							oci_close($conn);
							header('location: data_entry.php');
							exit();
						}

			}

}
	else
	{

		header('location: data_entry.php');
		exit();
	}

?>

0 Ответов