search

Home  >  Q&A  >  body text

Can you come over and help me find out why the form content cannot be added to the database?

Why the data submitted by the add form cannot be transferred to the database, and it will be cleared when clicking Add. Comment out the add status at the end to determine if the connection to the database is possible. I have tried everything I can, but I don't know where the problem lies. Could you please help me find out where the problem is? I've been stuck on this problem for a long time. Thank you, thank you, thank you, I am grateful

屏幕截图(15).pngTable

<body>

<div>

<form action="addAction.php?action=add" method="get">

<fieldset>

....

</fieldset>

</div>

<div> <tr>

<td><a href ="../right.php">Return</td>

<td><input type="submit" name="submit" value="Add"></ td>

<td><input type="reset" name="reset" value="Reset"></td>

</tr>

</form>

</div>

action operation

<?php

include '../function/conn.php';


if ($db_select){

switch ($_GET['action']) {

case 'add'://add

$Rnumber = $_POST['Rnumber'];

$Raddress = $_POST['Raddress'];

$Rtype = $_POST['Rtype'];

$Rstate = $_POST['Rstate'];

$Remark = $_POST['Remark'];

$sql = "insert into room (room_id, room_address, room_type, room_state, room_remark) values ​​('$Rnumber', '$Raddress','$Rtype','$Rstate','$Remark' )";

$rw = mysql_query($sql);

echo mysql_error();

if ($rw > 0){

echo "<script>alert('Add successfully');</script>";

                                                                                                                          ‐                              echo "                                                                                    echo " </script>";

                                                                                                                                                                                          

break;

?>

2132 days ago1558

reply all(4)I'll reply

  • jjJ

    jjJ2019-02-08 23:29:53

    Troubleshoot the problem step by step so you will understand

    reply
    0
  • 未完待续。。。

    未完待续。。。2019-01-29 11:04:32

    $sql = "insert into room (room_id, room_address, room_type, room_state, room_remark) values ​​('$Rnumber', '$Raddress','$Rtype','$Rstate','$Remark')";

    Print this sql statement and go to the mysql management tool to see if it can run.

    And "<form action="addAction.php?action=add" method="get">",

    You use get to submit the form, and use post to receive the data.

    $Rnumber = $_POST['Rnumber'];

    $Raddress = $_POST['Raddress'];

    $Rtype = $_POST['Rtype'] ;

    $Rstate = $_POST['Rstate'];

    $Remark = $_POST['Remark'];


    reply
    0
  • 韦小宝

    韦小宝2019-01-28 11:26:44

    How can I help you see it like this? You print it yourself in the background and debug it slowly

    reply
    0
  • Cancelreply