Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php不使用SQL数据库和插入值_Php_Html_Sql_Oracle_Insert - Fatal编程技术网

Php不使用SQL数据库和插入值

Php不使用SQL数据库和插入值,php,html,sql,oracle,insert,Php,Html,Sql,Oracle,Insert,嗨,如果你去,你会发现在这种情况下网页工作或不工作。我希望程序能做的是,如果没有post操作,则显示表单,但是如果有post操作,则用表单的详细信息替换表单条目。以及将详细信息添加到SQL数据库中。然而,它现在只是多次重复表和表单。有人能帮我快速看一下这个问题,并尝试帮助解决这个问题吗? 干杯 杰西 代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml

嗨,如果你去,你会发现在这种情况下网页工作或不工作。我希望程序能做的是,如果没有post操作,则显示表单,但是如果有post操作,则用表单的详细信息替换表单条目。以及将详细信息添加到SQL数据库中。然而,它现在只是多次重复表和表单。有人能帮我快速看一下这个问题,并尝试帮助解决这个问题吗? 干杯 杰西

代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0  Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Assignment 1 - SIT 104 - 214151511</title>
<!--This is where the Classes and Division Styles are setup for recall later in the code-->
<style type="text/css">

#Wrapper{
        Background:url(images/Crests.png);
        background-size:26%;
        background-position:top 6px;
        height:100%;
}

#NavBar{
    Height:26%;
    Border:groove Gold 6px;

}

#Body{
            Height:76%;
            border:groove Gold 6px;
            text-align:center;

    }

#Footer{
            Height:26%;
            background:#999;
            Border:groove gold 6px;

    }
</style>


</head>

<body>
<!-- This is the php to setup the connection to the oracle database needed to record information and to display reciept -->

<?php

/* Set oracle user login and password info */
$dbuser = "jrhaywar"; /* your deakin login */
$dbpass = "haybreaker"; /* your oracle access password */
$db = "SSID";
$connect = OCILogon($dbuser, $dbpass, $db);

if (!$connect) {
echo "An error occurred connecting to the database";
exit;
}

/* build sql statement using form data */
$query = "SELECT * FROM sit104Items";
if(isset($_POST['Submit'])){
    $name = $POST_['Name'];
    $phone = $POST_['Phone'];
    $email = $POST_['Email'];
    $reason = $POST_['Reason'];
    $message = $POST_['Message'];       

    $insert = $insert = "INSERT INTO ContactUs VALUES     ('$name','$phone','$email','$reason','$message')";
    $Insert = OCIParse($connect, $insert);
    }
    /* check the sql statement for errors and if errors report them */
    $stmt = OCIParse($connect, $query);
    //echo "SQL: $query<br>";
    if(!$stmt) {
    echo "An error occurred in parsing the sql string.\n";
    exit;
    }
    OCIExecute($stmt);

    ?>

<!--This is the beggining of the code that will be shown in the browser Starting with the wrapper and     Navigation bar and then continuing with the "body" division and ended by the footer-->
<div id="Wrapper">
<div id="NavBar">
 <table style="width:100%" height="10%" bgcolor="#CCFF00">
  <tr>
     <td width="26%" align="center" ><a link href="ass1.htm"><b>Home Page</b></a></td>
    <td width="26%" align="center"><a link href="Items.php"><b>Items</b></a></td>
    <td width="26%" align="center" ><a link href="FAQ.html"><b>FAQ/HELP</b></a></td>
    <td width="26%" align="center" ><a link href="Contact.html"><b>Contact Us</b></a></td>
  </tr>
</table>
</div>

<div id="Body">
<font size="6" face="Serpentine Bold" color="lime" ><b>
Welcome to the Order Page, please order what you wish!</b>
<hr/>
</font>
<?php
while(OCIFetch($stmt)){
/*Calculate what to do and show if Post is found*/
if(isset($_POST['Submit'])){
    echo('<table align="center" bgcolor="#00FF66" border="4" bordercolor="black" width="100%">
    <tr>
        <td  colspan="4" bgcolor="#00FFCC"><b>Personal and Delivery Details</b></td>
    </tr>
    <tr>
        <td width="6%" >Name:</td>
        <td width="46%" >');
    $fg1 = OCIResult($stmt, "NAME");
    echo $fg1;
    echo('</td>
        <td width="6%" >Phone Number:</td>
        <td width="46%" >');
    $fg2 = OCIResult($stmt, "PHONE");
    echo $fg2;
    echo('</td>
    </tr>
    <tr>
            <td width="10%">E-mail</td>
            <td width="80%" colspan="3">');
    $fg3 = OCIResult($stmt, "EMAIL");
    echo $fg3;
    echo('</td>
    </tr> 
    </table>
    <hr/>
    <table align="center" bgcolor="#00FF66" border="4" bordercolor="black" width="100%">
    <tr>
        <td colspan="2" bgcolor="#00FFCC" ><b>Message</b></td>
    </tr>
    <tr>
        <td width="10%">Reason for message:</td>
        <td width="90%">');
    $fg4 = OCIResult($stmt, "REASON");
    echo $fg4;
    echo('</tr>
    <tr>
        <td width="10%">Type Message Here: </td>
        <td width="90%">
    ');
    $fg5 = OCIResult($stmt, "MESSAGE");
    echo $fg5;
    echo('</td>
    </tr>
    </table>');


} /*End of the First If. So now compute what to do if post isn't used */


else


{
    echo('
<form name="ContactForm" onSubmit="Contact.php" >
<table align="center" bgcolor="#00FF66" border="4" bordercolor="black" width="100%">
<tr>
    <td  colspan="4" bgcolor="#00FFCC"><b>Personal and Delivery Details</b></td>
</tr>
<tr>
    <td width="6%" >Name:</td>
    <td width="46%" ><input Type="text" name="Name" style="width:86%"/></td>
    <td width="6%" >Phone Number:</td>
    <td width="46%" ><input type="text" Name="Phone" style="width:86%"/></td>
</tr>

<tr>
    <td width="10%">E-mail</td>
    <td width="80%" colspan="3"><input type="text" name="Email" style="width:30%" /></td>
</tr>

</table>
<hr/>
<table align="center" bgcolor="#00FF66" border="4" bordercolor="black" width="100%">
<tr>
    <td colspan="2" bgcolor="#00FFCC" ><b>Message</b></td>
</tr>
<tr>
    <td width="10%">Reason for message:</td>
    <td width="90%"><select name="Reason">
                    <option value="General Enquiry" >General Enquiry</option>
                    <option value="Returning Item" >Returning Item</option>
                    <option value="Missing Item" >Missing Item</option>
                    <option value="Price Negotiation">Price Negotiation</option>
                    </select>
</tr>
<tr>
    <td width="10%">Type Message Here: </td>
    <td width="90%"><textarea name="Message"  rows="5" style="width:90%;height:100%;"></textarea>            </td>
</tr>
</table>


<input type="submit" value="Send Message" style="width:95%; height:35px; margin-top:10px; background-    color:#0F0"/>

</form>
');}
}
OCILogOff($connect);
?>

 <br/>

</div>

<div id="Footer">

Links:<br/>
<a href="ass1.htm">Home</a><br/>
<a href="Items.php">Items</a><br/>
<a href="Order.html">Order Form</a><br/>
<a href="FAQ.html">faq/help</a><br/>
<a href="Contact.html">Contact Us</a><hr/>

<p align="left">
©Deakin University, School of Information Technology. This web page has been developed as a student assignment for the unit SIT104: Introduction to Web Development. Therefore it is not part of the         University's authorised web site. DO NOT USE THE INFORMATION CONTAINED ON THIS WEB PAGE IN ANY WAY
</p>

</div>
</div>
</body>
</html>

我看到在查看时我忽略了双插入,我不需要给出列名,如果所有collumn都是按正确的顺序由值填充的,我应该吗?-即使编辑了这两个东西,我仍然有相同的问题。嗨,我会尝试一下,我通过删除WhileOCIFetch$stmt修复了第一个存在多行的错误{…由于这不会给我所需的结果,现在唯一的事情是让它用刚输入的详细信息替换表单条目。我刚刚意识到您刚才发送给我的代码已经在那里了,好像!$stmt{echo解析sql字符串时出错。\n;exit;}