douan4106 2013-07-08 16:25
浏览 21
已采纳

提交返回空白页面

A blank page is returned when I try to add a new note. My code is in php and the DB is mysql

This is the php code:

if (isset($_POST['Submit'])) {

$candidate_id = $_POST['candidate_id'];
$Notes=$_POST['notes'];
if ($Notes != "") {

$sql3="INSERT INTO notes (notes_id, candidate_id, notes)
VALUES(DEFAULT,'$candidate_id','$Notes')";

$result3=mysql_query($sql3);

if (!$result3)
{
die('Error: ' . mysql_error());
 }
 echo "</br>1 note added"

  }
  }
 mysql_close();

The code for the form

<div id ="tab3">
    <h2> Notes </h2>
    <dl><dt>Notes</dt><dd><textarea id="notes" style="width: 80%; height: 150px;" name="notes"></textarea></dd></dl>
          <?php   echo "<a href =newCandidate.php?id=$contact_id><input style =\"right:2em; bottom:1em;\" type =\"button\" name =\"update\" value =\"Submit\"></a>";
       ?>   </div>
  • 写回答

4条回答 默认 最新

  • doutongya8378 2013-07-08 16:41
    关注

    try

    if($_SERVER['REQUEST_METHOD']=="POST"){
    

    or

    if(isset($_POST['update'])){
    

    instead of

     if (isset($_POST['Submit'])) {
    

    the name of the submit button is update not Submit on your form

    also stop using mysql_* functions. If you have to use them for now, at least escape the inputs properly before inserting them to database.

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

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号