Search the Community
Showing results for tags 'request'.
-
I've been trying to figure out how chat apps work all afternoon to do dynamic data in HTML loading. Can someone please tell me where I'm going wrong for the code flow in this script: <script> function submitchat{ if (form1.uname.value=='' || form1.msg.value==''){ alert("fill out whole form"); return; } var uname=form1.uname.value; var msg=form1.msg.value; var xmlhttp= new XMLHttpRequest(); xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState==4 && xmlhttp.status=200){ document.getElementById('chatlogs').innerHTML=xmlhttp.responseText; alert("message sent"); } xmlhttp.open('GET', '?page=3.2&uname='+uname+'&msg='+msg, true); xmlhttp.send(); } </script> <form name="form1"> enter your chat name<input type="text" name="uname"> message: <textarea name="msg"></textarea> <br> <div id="chatlogs">Loading Chat Logs...</div> <a href="#" onclick="">send</a> </form> <?php $uname = $_REQUEST['uname']; $msg = $_REQUEST['msg']; if ($msg!='' && $uname!=''){ $chat=" INSERT INTO chat ( `uname` , `msg` ) VALUES ( '$uname', '$msg' )"; $result = mysql_query($chat, $con) or die (sql_death($chat)); }
- 5 replies
-
- chat
- javascript
-
(and 2 more)
Tagged with:
-
Hi guys, I am trying to figure out how to pass PHP ID (page.php?id= 'id' ") with ajax request. Getting the ID and storing it into variable called "playlistsongid" <?php session_start(); if(!isset($_GET['id'])) die("No id set"); ?> <?php $playlistsongid = $_GET['id']; ?> function setupyoutubesongarray(firstload) { $.ajax({ 'url': 'post.php', 'async': false, success: function (response) { var posturl="post.php"; // needs to looks something like post.php?id= $.getJSON(posturl,function(data){ youtubesongs = []; $.each(data.members, function(i,song){ result = (song.SongUrl); youtubesongs.push(result); //ytplayer_playlist.push(result); }); loadnextbatchfromsongsarray(); if (firstload = 1) { ytplayer_render_player(); } }); } }); } Any help would be much apreceated!
-
i'll looking for a snippet of code in php to post a set of variables to a url and then display the return data. example: &field1=a&field2=b&field3=3 https://www.example.com/dir/ i searched for a few hours and cannot put the code together. most of the php sites talk about post and get functions, but i cannot find a good, rather working, example. do i need two php pages, one to call the other? do i use html form submit? what tells the page to just display/print the response. i'm sure i can figure out how to parse the info but i'm stuck on first step, post-get data. thanks in advance!
-
Hi, I'm after a song search request script to be made for my website below is some info and bullet points of what I would like the script to have. > Search box and the php script will read a .csv file and show matching data > Search results to show up in table column 1 radio button, column 2 Artists, column 3 tracks, > Above results search box below search results a contact form that will email song request and Name (mandatory), email (mandatory) Dedicate (optional) comment (optional) to my own email address > Alphabetical listing (ie clicking A will show all artists beginning with A) Above search box I do have some other ideas - email me and I'll give you my Skype ID so we can talk more
-
Hello All! I am having an issue with requesting some information for certain blog post. I have written a blog in PHP and have come accross an issue when trying to look up certain articles with certain "Tags". Right now the system pulls up and counts the tag's correctly but when I am trying to click the name of the tag to view post only related to that tag, it keeps giving me trouble. Here is the code I have been using for sending and getting the information. First is the function I am using to count the tags and create a link to use function getTagCount($DBH) { //Make the connection and grab all the tag's TAG TABLE HAS TWO FIELDS id and name $stmt = $DBH->query("SELECT * FROM tags"); $stmt->execute(); //For each row pulled do the following foreach ($stmt->fetchAll() as $row){ //set the tagId and tagName to the id and name fields from the tags table $tagId = $row['id']; $tagName = ucfirst($row['name']); //Next grab the list of used tags BLOG_POST_TAGS TABLE HAS TWO FILEDS blog_post_id and tag_id $stmt2 = $DBH->query("SELECT count(*) FROM blog_post_tags WHERE tag_id = " . $tagId); $stmt2->execute(); $tagCount = $stmt2->fetchColumn(); //Print the following list echo '<li><a href="blog_tags.php?=tagId=' . $tagId . '"title="' . $tagName . '">' . $tagName . '(' . $tagCount . ')</a></li></form>'; //End of loop - start again } } Now here is the code I am using on the page it is being directed too(blog_tags.php) <?php include "includes.php"; $blogPosts = GetTaggedBlogPosts($_GET['tagId'],$DBH); foreach ($blogPosts as $post) { echo "<div class='post'>"; echo "<h2>" . $post->title . "</h2>"; $body = substr($post->post, 0, 300); echo "<p>" . nl2br($body) . "... <a href='post_view.php?id=" . $post->id . "'>View Full Post</a><br /></p>"; echo "<span class='footer'><strong>Posted By:</strong> " . $post->author . " <strong>Posted On:</strong> " . $post->datePosted . " <strong>Tags:</strong> " . $post->tags . "</span><br />"; echo "</div>"; } ?> Here is also the function I am using function GetTaggedBlogPosts($postTags, $DBH) { if (!empty($postTags)) { $postTagsIDsql = "SELECT blog_post_id FROM blog_post_tags WHERE tag_id = :postTagID"; $postTagIDparam = array( ':postTagID' => $postTags ); $postTagIDstmt = $DBH->prepare($postTagsIDsql); $postTagIDstmt->execute($postTagIDparam); $blogstmt = $DBH->prepare("SELECT * FROM blog_post WHERE id = :blog_id ORDER BY id DESC"); $blogstmt->bindParam(":blog_id", $postTagsIDstmt, PDO::PARAM_INT); $blogstmt->execute(); } else { echo 'I apologize about there does not seem to be any post with that related tag.'; } $postArray = array(); $results = $blogstmt->fetchAll(PDO::FETCH_ASSOC); foreach($results as $row){ $myPost = new BlogPost($row["id"], $row['title'], $row['post'], $row['author_id'], $row['date_posted'], $DBH); array_push($postArray, $myPost); } return $postArray; } I am just looking for a point in the right direction and to point out where my break down is happening. Thanks in advanced for your time, learning PHP on my own has been a chore but you all have helped make learning it so much easier.