Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am writing a web application using oracle sequal sql. I am trying to get a pag

ID: 3822921 • Letter: I

Question

I am writing a web application using oracle sequal sql. I am trying to get a page working that will let the user insert three records into my database application. I created a procedure called "insertStudent" to insert the three items, student number, first name and lastname. I tested the stored procedure and it works fine and executes fine when I try using it in the oracle sql*plus command line window. I want it to work with the webpage a created letting the user click a button to make php push the info to my database. It wont work and I am not sure why. If you could show the solution and explain how you got it to work, I will upvote good response. Please test to maks sure it works if you can. Thanks

<html>
<head>


<style>

input[type=text] {
    padding:5px;
    border:2px solid #ccc;
    -webkit-border-radius: 5px;
    border-radius: 5px;
}

input[type=text]:focus {
    border-color:#333;
}

input[type=submit] {
    padding:5px 15px;
    background:#ccc;
    border:0 none;
    cursor:pointer;
    -webkit-border-radius: 5px;
    border-radius: 5px;
}

</style>

</head>

<body>


<!--
php version, make sure not vb stuff ....
-->

<form action="" method="post">
Student Number: <input type="text" name="HTML_StudentNumber" size="20"><br>
First Name: <input type="text" name="tStudentfName" size="20"><br>
Last Name: <input type="text" name="tStudentlName" size="20"><br>
<input type="submit" name="insert_btn" value="Submit">
</form>

<!--
The setting of the above form is consistent to the table that we will deal with
So, make sure you have created the below table under your account.

check out sample sql script

-->

<?php

# $conn = oci_connect('username', 'password', 'csci242');
$connect = oci_connect('username', 'password', 'csci242');

if (isset($_POST["insert_btn"]))
{

$sql = "CALL insertStudent('".$_POST["HTML_StudentNumber"]."',
'".$_POST["tStudentfName"]."', '".$_POST["tStudentlName"]."',)";
if (oci_query($connect, $sql))
   {
   header("location:index.php?inserted=1");
   }
}
if (isset($_GET["inserted"]))
{
   echo '<script>alert("data inserted")</script>';
}


?>

<p>
<button>Go Back to previous Page</button>
</p>

<script>
function goBack() {
    window.history.go(-1);
}
</script>

</body>
</html>

Explanation / Answer

Kindly try this code,

The problem was because of the extra "," you have added while calling insertStudent procedure.

$sql = "CALL insertStudent('".$_POST["HTML_StudentNumber"]."',
'".$_POST["tStudentfName"]."', '".$_POST["tStudentlName"]."',)";

<html>
<head>

<style>
input[type=text] {
padding:5px;
border:2px solid #ccc;
-webkit-border-radius: 5px;
border-radius: 5px;
}
input[type=text]:focus {
border-color:#333;
}
input[type=submit] {
padding:5px 15px;
background:#ccc;
border:0 none;
cursor:pointer;
-webkit-border-radius: 5px;
border-radius: 5px;
}
</style>
</head>

<body>

<!--
php version, make sure not vb stuff ....
-->
<form action="" method="post">
Student Number: <input type="text" name="HTML_StudentNumber" size="20"><br>
First Name: <input type="text" name="tStudentfName" size="20"><br>
Last Name: <input type="text" name="tStudentlName" size="20"><br>
<input type="submit" name="insert_btn" value="Submit">
</form>
<!--
The setting of the above form is consistent to the table that we will deal with
So, make sure you have created the below table under your account.
check out sample sql script
-->
<?php

# $conn = oci_connect('username', 'password', 'csci242');
$connect = oci_connect('username', 'password', 'csci242');

if (isset($_POST["insert_btn"]))
{
$sql = "CALL insertStudent('".$_POST["HTML_StudentNumber"]."',
'".$_POST["tStudentfName"]."', '".$_POST["tStudentlName"]."')";
if (oci_query($connect, $sql))
{
header("location:index.php?inserted=1");
}
}
if (isset($_GET["inserted"]))
{
echo '<script>alert("data inserted")</script>';
}

?>
<p>
<button>Go Back to previous Page</button>
</p>
<script>
function goBack() {
window.history.go(-1);
}
</script>
</body>
</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote