dongsaolian8786 2012-12-22 21:07
浏览 13
已采纳

多次检查后,PHP文件没有显示任何内容

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 !

  • 写回答

2条回答 默认 最新

  • duancaozen6066 2012-12-22 21:20
    关注

    It looks like the input names in your form don't match what you are trying to get from $_POST in your PHP code.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 12864只亮屏 不显示汉字
  • ¥20 三极管1000倍放大电路
  • ¥15 vscode报错如何解决
  • ¥15 前端vue CryptoJS Aes CBC加密后端java解密
  • ¥15 python随机森林对两个excel表格读取,shap报错
  • ¥15 基于STM32心率血氧监测(OLED显示)相关代码运行成功后烧录成功OLED显示屏不显示的原因是什么
  • ¥100 X轴为分离变量(因子变量),如何控制X轴每个分类变量的长度。
  • ¥30 求给定范围的全体素数p的(p-2)/p的连乘积值
  • ¥15 VFP如何使用阿里TTS实现文字转语音?
  • ¥100 需要跳转番茄畅听app的adb命令