Jump to content

INSERT doesn´t work!


beginann

Recommended Posts

Probably I am blind, but I can´t see what´s wrong with my code...
I have databaseconnection, but I can´t insert any new posts in my database from my form.
Please help!
Many thanks!
Beginann

This is my code:

php
include_once("dbmanager.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Växtdatabas, blomform</title>
<link href="vaxter_css.css" rel="stylesheet" type="text/css" />
</head>

<body>
<?php
  if(isset($save)){
        if(isset($blomform) && $blomform != "" && strlen($blomform) <= 30) {
      $query = "INSERT INTO blomform (blomform) VALUES ('$blomform')";
      $resultat = mysql_query($query,$connection);
        if(!$resultat){
            echo "<div class=tabell4><table><tr><td>The flower couldn´t be put into the database!
MySQL rapporterar: " .mysql_error() ."</td>
            </tr>";
            echo "</table></div>"; }
        else
            echo "Blomformen $blomform är inlagd.";
        }
  }
  // Close connection to database
    mysql_close($connection);
?> 
<form method="post" action="<?=$PHP_SELF?>">
<span class="rubrik">L&auml;gg till blomform</span>
<table width="33%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>Blomform</td>         
    <td>  <input type="text" name="blomform"  size="30" /></td></tr>
    <tr><td>&nbsp;</td><td colspan="2"></tr>
    <tr><td>&nbsp;</td>
    <td colspan="2"><input class="skicka_knapp3_gul"  type="submit" name="save" value="Save" />
    </tr>
</table>
</form>
</body>
</html>
Link to comment
https://forums.phpfreaks.com/topic/25911-insert-doesn%C2%B4t-work/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.