Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(isset($_GET['action'])){
- if($_GET['action'] == "update"){
- $myServer = "(local)";
- $myUser = "Gotactics";
- $myPass = "gosteven22";
- $myDB = "Gotactics";
- $link = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer");
- $db = mssql_select_db($myDB, $link) or die("Couldn't open database $myDB");
- $res = mssql_query("SELECT * FROM User_Shoutbox ORDER BY date", $link);
- while(($row = mssql_fetch_array($res))&&($row['id']<=20)){
- $Date_Sent = date('d-m-Y', strtotime($row['date']));
- $result = $row['user'].$row['message'].$Date_Sent;
- echo $result;
- mssql_close($link);
- }
- if($_POST['action'] == "insert"){
- if(isset($_POST['message'])){
- $message = $_POST['message'];
- }
- if(isset($_POST['user'])){
- $message = $_POST['user'];
- }
- $myServer = "(local)";
- $myUser = "Gotactics";
- $myPass = "gosteven22";
- $myDB = "Gotactics";
- $link = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer");
- $db = mssql_select_db($myDB, $link) or die("Couldn't open database $myDB");
- $query = "INSERT INTO User_Shoutbox(user, message) VALUES('".$user."','".$message."'";
- $res = mssql_query($query,$link);
- mssql_close($link);
- }}
- }
- else{
- header ("Location: index.php");
- }
- /////////////////////////////////////////////////////
- This checks if the POST action is recieved into the methods. and if so it uses the Insert statement to Insert a table and Update to Show the table Now it shows the table fine but it does not Insert at all. instead of showing after insert or inserting it shows my web page inside a smaller version of the shoutbox.
- ////////////////////////////////////////////////////////
- $("#form").submit(function(){
- if(checkForm()){
- var nick = inputUser.attr("value");
- var message = inputMessage.attr("value");
- //we deactivate submit button while sending
- $("#send").attr({ disabled:true, value:"Sending..." });
- $("#send").blur();
- //send the post to shoutbox.php
- $.ajax({
- type: "POST", url: "shoutbox.php", data: "action=insert&nick=" + nick + "&message=" + message,
- complete: function(data){
- messageList.html(data.responseText);
- updateShoutbox();
- //reactivate the send button
- $("#send").attr({ disabled:false, value:"Shout it!" });
- }
- });
- }
- else alert("Please fill all fields!");
- //we prevent the refresh of the page after submitting the form
- return false;
- });
- ///////////////////////////////////
- This posts the variable to the files in shoutbox.php to insert and update
- //////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement