Jump to content

jquery stops insert into database


simonij

Recommended Posts

Hello all, i have made this script but then i press submit the jquery animation start but it will not submit it into the database with PHP :S.

 

Here is my script

 

<?php
session_start();
include("config.php");

if(isset($_POST['opret']))
{
    $navn   = $_POST['navn'];
    $besked = $_POST['besked'];
    $klok   = "123";
    $dato   = "123";
    $ip     = $REMOTE_ADDR;
    $farve  = $_POST['farve'];
    
mysql_query("INSERT INTO tags (id, navn, besked, ip, klok, dato, farve) VALUES ('', '".$navn."', '".$besked."', '".$ip."', '".$klok."', '".$dato."', '".$farve."')") or die(mysql_error());
    
}#Lukker isset opret
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">

<html>
<head>
    <title>Tagwall V2</title>
    <link href="designstyle.css" rel="stylesheet" type="text/css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
    
    <script type="text/javascript">
    
         $(document).ready(function(){
           $("#opret_besked").click(function(event){
                $('#godkendt').slideDown('slow');
                $('#godkendt').fadeOut(4000);
                $.post('tagwall.php', $('#opretForm').serialize());
                return false;
           });
         });

    
    
    
    </script>
    
    
</head>

<body>
<div style='background-color:#e3ffdf; border:1px solid #97ff88; display:none; color:#009900; width:99.9%; height:30px; padding-top:15px; position:absolute; top:0px; left:0px; text-align: center;' id='godkendt'><b>Beskeden blev oprettet med succes!</b></div><!-- godkendt -->

    <div id="ramme">
    
        <div id="venstreRamme">
        
            <div id="besked">
                <h1>Opret besked:</h1>
            
                <form id="opretForm" method="post" name="besked">
                    Navn:<br />
                    <input type="text" name="navn" />
                    Besked:<br />
                    <input type="text" name="besked" />
                    <br />
                    <input id="opret_besked" type="submit" name="opret" value="Opret" />
                </form>
            
            </div><!-- besked -->

            <div id="online">
            <h1>Online brugere:</h1>
            
                <?php
                $hent_online = mysql_query("SELECT id,ip FROM online") or die(mysql_error());
                while($vis_online = mysql_fetch_array($hent_online))
                {
                    echo "#<b>".$vis_online['id']."</b> ";
                    echo "<i>".$vis_online['ip']."</i>";
                    echo "<br />";
                    
                }
                
                ?>
            
            
            </div><!-- online -->
            
        </div><!-- venstreRamme -->


        <div id="tags">
        
                <?php
                $skrift_bg == 0;
                $hent_tags = mysql_query("SELECT * FROM tags ORDER BY id DESC") or die(mysql_error("Kan ikke connecte til databasen"));
                while($vis_tags = mysql_fetch_array($hent_tags))
                {

                    
                    if($skift_bg == 0)
                    {
                        
                    echo "<font color='#". $vis_tags[farve]."'><b>".$vis_tags[navn].":</b></font> ";
                    echo "<font color='#7c7c7c'>".$vis_tags['besked']."</font><br>";
                    
                    $skrift_bg == 1;
                    } else {
                    
                    echo "<div style='background-color:#000;' id='bg_farve'>";
                    echo "<font color='#". $vis_tags[farve]."'><b>".$vis_tags[navn].":</b></font> ";
                    echo "<font color='#7c7c7c'>".$vis_tags['besked']."</font><br>";
                    echo "</div><!-- bg_farve -->";
                        
                        
                    }
                    
                    
                }
                
                ?>
        
        </div><!-- tags -->
        
        
    </div><!-- ramme -->
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/185942-jquery-stops-insert-into-database/
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.