Hello everyone, I have a PHP form that connects to an oracle DB and should send data to the database when the form is submitted, but I can't figure out why it's not loading any of the data into the database, everything seems to be correct (though this is my first time attempting something like this, so I am likely wrong).
Is there something wrong with the way in which I've structured this page, or something wrong with the way I'm binding variables? Why isn't this properly working?
Note: I changed the connect string to a fake one for security.
Any tips and helps would be greatly appreciated, thanks!
> <?php
> //ini_set('display_errors', 'On');
> //error_reporting(E_ALL | E_STRICT);
> //include("insert.php");
>
> $conn = oci_connect("user", "password", "//path/to");
> if (!$conn) {
> $m = oci_error();
> echo $m['message'], "\n";
> exit;
> }
> else {
> print "You are connected to the VTC database!<br/>";
> }
> $issueType = $_POST['issueType'];
> $summary = $_POST['summary'];
> $endPointName = $_POST['endPointName'];
> $contactFirstName = $_POST['contactFirstName'];
> $contactLastName = $_POST['contactLastName'];
> $contactEmail = $_POST['contactEmail'];
> $contactPhone = $_POST['contactPhone'];
> $description = $_POST['description'];
> $solution = $_POST['solution'];
> $ticketNumber = $_POST['ticketNumber'];
> $resolved = $_POST['resolved'];
> $agency = $_POST['agency'];
>
> $insert = 'INSERT INTO VTC_HELPDESK_ISSUES(ISSUE_TYPE,ISSUE_SHORT,ENDPOINT_NAME,CONTACT_FIRST_NAME,CONTACT_LAST_NAME,CONTACT_EMAIL,CONTACT_PHONE,ISSUE_DESC,SOLUTION,OTHER_COMPANY_TICKET_NUM,RESOLVED,AGENCY ) '.
> 'VALUES(9, :issueType, :summary, :endPointName, :contactFirstName, :contactLastName, :contactEmail, :contactPhone, :description, :solution, :ticketNumber, :resolved, :agency)';
>
> $send = oci_parse($conn, $insert);
>
> //Binding makes it harder to submit anything directly to the Oracle DB
> oci_bind_by_name($send, ':issueType', $issueType);
> oci_bind_by_name($send, ':summary', $summary);
> oci_bind_by_name($send, ':endPointName', $endPointName);
> oci_bind_by_name($send, ':contactFirstName', $contactFirstName);
> oci_bind_by_name($send, ':contactLastName', $contactLastName);
> oci_bind_by_name($send, ':contactEmail', $contactEmail);
> oci_bind_by_name($send, ':contactPhone', $contactPhone);
> oci_bind_by_name($send, ':description', $description);
> oci_bind_by_name($send, ':solution', $solution);
> oci_bind_by_name($send, ':ticketNumber', $ticketNumber);
> oci_bind_by_name($send, ':resolved', $resolved);
> oci_bind_by_name($send, ':agency', $agency);
>
> oci_execute($send);
>
> ?>
>
> <!DOCTYPE html>
> <html>
> <head>
> <!--<title>VTC Issues Entry</title>-->
> <meta charset="utf-8" />
> </head>
>
> <body>
>
> <form>
> <fieldset id = "vtcForm">
> <form action="form.php" id="insert" method="post">
>
> <!--Issue Type-->
> <label for="issueType"><b>Issue Type</b><br/></label>
> <select name="issueType" id = "issueType">
> <option>Support</option>
> <option>Hardware</option>
> <option>External Call</option>
> <option>Other</option>
> </select>
> <br/><br/>
>
> <!--Short Description-->
> <!--<form method="post" action="">-->
> <b>Summary of the Issue</b><br/>
> <textarea name="summary" id = "summary" cols="50" rows="10">
> </textarea>
> <!--<input type="submit" value="Submit" />
> </form>-->
> <br/><br/>
>
> <!--Endpoint Name-->
> <?php print '<label for="testOption"><b>Test Option</b><br/></label>
> <select name="endPointName" id = "endPointName">';
$conn = oci_connect("user", "password", "//path/to");> $query = 'select endpoint_name from endpoint_ref';
> $stid = oci_parse($conn, $query);
> $result = oci_execute($stid);
> while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS+OCI_ASSOC)) {
> foreach ($row as $item) {
> print '<option>'.($item !== null ? htmlentities($item, ENT_QUOTES) : ' ').'</option>'; // but you should include an id or something for the option value
> }
> }
> print '</select>';?>
> <br/><br/>
>
> <!--Contact Name-->
> <label for="contactFirstName"><b>Contact Name</b><br/></label>
> <input type = "text"
> name = "contactFirstName"
> id = "contactFirstName"
> value = "Herp Derp"
> />
> <br/><br/>
>
> <!--Contact Name-->
> <label for="contactLastName"><b>Contact Name</b><br/></label>
> <input type = "text"
> name = "contactLastName"
> id = "contactLastName"
> value = "Derp"
> />
> <br/><br/>
>
> <!--Contact Email-->
> <label for="contactEmail"><b>Contact E-Mail</b><br/></label>
> <input type = "text"
> name = "contactEmail"
> id = "contactEmail"
> value = "Herp@Derp.com"
> />
> <br/><br/>
>
> <!--Contact Phone Number-->
> <label for="contactPhone"><b>Contact Phone Number</b><br/></label>
> <input type = "text"
> name = "contactPhone"
> id = "contactPhone"
> value = "0123456789"
> />
> <br/><br/>
>
> <!--Description of Issue-->
> <b>Full Description of Issue</b><br/>
> <textarea name="description" cols="50" rows="10">
> </textarea>
> <br/><br/>
>
> <!--Description of Solution-->
> <b>Solution</b><br/>
> <textarea name="solution" cols="50" rows="10">
> </textarea>
> <br/><br/>
>
> <!--Ticket Number Reference-->
> <label for="ticketNumber"><b>Ticket Number Reference</b><br/></label>
> <input type = "text"
> name = "ticketNumber"
> id = "ticketNumber"
> value = "9876543210"
> />
> <br/><br/>
>
> <!--Resolved-->
> <label for="resolved"><b>Resolved?</b><br/></label>
> <select name="resolved" id = "resolved">
> <option>Yes</option>
> <option>No</option>
> </select>
> <br/><br/>
>
> <!--Agency-->
> <label for="agency"><b>Agency</b><br/></label>
> <select name="agency" id = "agency">
> <option>1</option>
> <option>2</option>
> <option>3</option>
> </select>
> <br/><br/>
>
> </fieldset>
> <input type="submit" value=" Submit " name='insert' />
> </form>
>
> </body>
> </html>