So I have been asked to insert rows to this database using a html form. Here's the code of the form:
<html>
<body>
<div id="header1">
<h1>Donar d'alta un client</h1>
</div>
<hr>
<form action="alta.php" method="post">
Numero: <input type="text" name="cnumero" /><br>
Nom: <input type="text" name="cnom" /><br>
Adreca: <input type="text" name="cadreca" /><br>
Codi Postal: <input type="text" name="ccp" /><br>
Poblacio: <input type="text" name="cpob" /><br>
Dni: <input type="text" name="cdni" /><br>
Email: <input type="text" name="cemail" /><br>
<input type="submit" value="Afegeix" />
</form>
<hr>
</body>
</html>
That's a normal form, nothing special, it works. Now here it comes the problem. In the file alta.php, I have the PHP code to insert all this information in a row of this existing table. The table is called CLIENT and it has all this parameters and 3 more which have to be NULL when you add a new row. Here's the code of alta.php :
<html>
<body>
<?php
include 'vars.php';
ini_set('display_errors', 1);
error_reporting(E_ALL);
$numero= $_POST['cnumero'];
$nom= $_POST['cnom'];
$adreca= $_POST['cadreca'];
$codi_postal= $_POST['ccp'];
$poblacio= $_POST['cpoblacio'];
$dni= $_POST['cdni'];
$email= $_POST['cemail'];
$conn = oci_connect('u*******', 'u*******', '********');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['No em connectat a la BD'], ENT_QUOTES), E_USER_ERROR);
}
$stid = oci_parse($conn, "INSERT INTO client
(client_num, client_nom, client_adreca, client_codi_postal, client_poblacio, client_dni, client_email)
VALUES
(:client_num, :client_nom, :client_adreca, client_codi_postal, :client_poblacio, :client_dni, :client_email)");
oci_bind_by_name($stid, ":client_num", $numero);
oci_bind_by_name($stid, ":client_nom", $nom);
oci_bind_by_name($stid, ":client_adreca", $adreca);
oci_bind_by_name($stid, ":client_codi_postal", $codi_postal);
oci_bind_by_name($stid, ":client_poblacio", $poblacio);
oci_bind_by_name($stid, ":client_dni", $dni);
oci_bind_by_name($stid, ":client_email", $email);
$r = oci_execute($stid);
if ($r) { echo 'Client afegit correctament.'; }
if (!$r){ echo 'Hi ha hagut un error.'; }
oci_free_statement($stid);
oci_close($conn);
?>
<br><br><br>
<div id="tornar">
<li><a href="index2.html">Tornar a l'inici</a></li>
</div>
</body>
</html>
The problem is my browser keeps saying there's an 'Internal Server Error'. So apparently there's a piece of this code which doesn't work. Could you guys help me a bit? I've spent way too much time thinking about it and I can't see what's wrong.
Thanks a lot !