Jump to content

Nightasy

Members
  • Posts

    65
  • Joined

  • Last visited

About Nightasy

  • Birthday 02/21/1982

Profile Information

  • Gender
    Male

Nightasy's Achievements

Member

Member (2/5)

1

Reputation

  1. @maxxd - Thanks for catching that deprecation. I completely missed it and the .on() is really identical in functionality so all I had to do with change that one command. It didn't solve the issue I was having here though. The issue revolves around how Wordpress makes use of Ajax on the backend. In the wordpress documentation on it they try to make it sound like they way they handled the use of Ajax is the "greatest most easiest thing evar!!!" when in reality they just made it ten times more complex to do. From my readings it had to do with security issues they ran into quite awhile back. Either way though, it doesn't matter anymore. My team has decided to make the menu external from wordpress anyhow for added security measures since it controls our entire entry database. No sense in taking any risks with wordpress (which has been known to have been hacked) when we know that we can lock it up like fort knox using an external platform if you know what I mean. I would like to know how to do ajax with wordpress plugins but I suppose that's just something that will have to wait. Thanks for taking a look either way.
  2. Greetings all, Been trying to make a plugin in wordpress and ran into an issue with the way wordpress makes use of ajax in the administration menu. The problem is that I completely don't understand it. I've read all the docs on it and even tried messing with a variety of tutorials on the matter to no avail. What I am trying to do is a simple task outside of wordpress. The form has two select fields, the first field populates the second selection field. While this works fine on a standard html page, trying to do it in wordpress is another story. Form.php: <div id="wrapper"> <h1>Second dropdown selection based </h1> <form action="" method="post"> <p><label>Main Menu :</label> <select name="main_menu_id" id="main_menu_id"> <option value="">Select</option> <?php // Connect to database. $connect = mysqli_connect('<!--DB connection info-->"); $q = mysqli_query($connect, "SELECT cfid,cfname FROM categoryfiles ORDER BY cfid"); while($row = mysqli_fetch_array($q)) { echo '<option value="' . $row['cfname'] . '">' . $row['cfname'] . '</option>'; } ?> </select> </p> <p><label>Sub Menu: </label> <select name="sub_menu_id" id="sub_menu_id"></select> </p> </form> </div> The script.js $(function() { $("#main_menu_id").bind("change", function() { $.ajax({ type: "GET", url: "scripts/get_sub_category.php", data: "main_menu_id="+$("#main_menu_id").val(), success: function(html) { $("#sub_menu_id").html(html); } }); }); }); The get_sub_category.php <?php // Connect to database. $connect = mysqli_connect('<!--My connection info-->); $id = $_GET['main_menu_id']; $q = mysqli_query($connect, "SELECT sfid, sfname FROM subjectfiles WHERE sfcategory='" . $id . "' ORDER BY sfname"); while($row = mysqli_fetch_array($q)) { echo '<option value="' . $row['sfname'] . '">' . $row['sfname'] . '</option>'; } ?> Like I said, it works just fine outside of wordpress so really I just need help getting it to work in wordpress. I just don't understand it. Thanks to anyone that takes the time to look this over. Best Regards, Nightasy
  3. That was it. See, I knew it was something simple and staring me right in the face. Sometimes you just need a fresh pair of eyes to point out a blatant mistake. Thank you very much.
  4. Greetings all, I have been developing a comment box for my site and I ran into an issue I can't seem to figure out. In my comment box when I am logged in as an admin I want to be able to delete comments by simply clicking a button. The comments are printed out from a database using a while loop: <?php echo '<div id="commentMainTitle"><h3>Video Comments</h3></div>'; while($row = mysqli_fetch_array($results, MYSQLI_ASSOC)){ echo '<div id="commentUniqueWrap"> <div id="commentUniqueTitleMessageWrap"> <div id="commentUniqueTitle"> <h4>'. stripslashes($row['name']) .'</h4>';?> <?php if (isset($_SESSION['admin'])){?> <!--If admin add form for delete comment.--> <form enctype="multipart/form-data" action="includes/function/deletecomment.php" method="post"> <input type="hidden" name="cursect" value="<?php echo $sect1;?>" /> <input type="hidden" name="curvideored" value="<?php echo $_GET['curvideo'];?>" /> <input type="hidden" name="postID" value="<?php echo $row['id'];?>" /> <input type="submit" name="submit" value="Delete" /> <?php echo $row['id']; } echo '</div> <div id="commentUniqueMess"> <p>' . stripslashes($row['comment']). '</p> <p class="datealign">' . $row['date'] . '</p> </div> </div> </div>'; } ?> When the comments are listed out a Delete button is listed next to the commentors name. A comment is deleted however it is not the comment that is selected for deletion. Instead the last comment that was echo'd out from the while loop is deleted. Here is the script that deletes the comment: <?php if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['postID'])){ //Requires the database connection script. require $_SERVER['DOCUMENT_ROOT'] . '/mywebsite/masters/connect.php'; $qdelete = "DELETE FROM comment WHERE id ='".$_POST['postID']."' LIMIT 1"; if (!mysqli_query($connect,$qdelete)){ die('Error: ' . mysqli_error($connect)); } // Close database connection. mysqli_close($connect); // Set path for redirect. $redirect = 'http://www.mywebsite.com/myvideos.php?sect=' . $_POST['cursect'] . '&curvideo=' . $_POST['curvideored']; // Redirect to previous page. echo '<script type="text/javascript"> setTimeout(redirect, 0000); function redirect() { location.href="'.$redirect.'" } </script>'; } ?> I'm not sure what the issue is or how to go about solving it. I feel like the answer is staring me in the face but I've been looking at the code for too long and it has me at a loss. Any help would be greatly appreciated. Thank you for your time. Best Regards, Nightasy
  5. Yea, I completely understand it. In my case, adding a ../ basically leaves out the folder that the page is in, since it is not in the root folder. I completely get it now, I just never looked into why and now I know. Adding a ../ would send it to my root/videos folder instead of the root/folder_my_page_is_in/videos folder. It makes sense.
  6. Well, I suppose that explains it. Like I said I never looked into it but yea, my entire site is inside of a folder and uses a splash screen index page at the root. So I guess that explains why I had the issue on my new server and why I had it in college too. In college I had to put my site in a folder due to the way they taught some restrictions with .htaccess and folder permissions. Perhaps this is the case for eatc7402, I'm happy to have learned what you just told me though. I always wondered why that was an issue for my current server (and in my college course too). Learn something new everyday.
  7. If you are asking me for an example, I suppose this would suffice. This is from the index.php page on my most recent project. <div id="introvideodiv"> <video poster="videos/1.jpg" preload="auto" controls> <source src="videos/placeholder.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' /> </video> If you'll notice, I have no ../ in the addresses for the poster and the video. If I add the ../ they won't work at all. No poster would show and no video would be located. My GoDaddy server is a shared server as far as I know and this is probably why I can't add the ../ in the addresses. I just figured I would mention it here because that little issue on my server stumped me for a couple hours when I first got the server through GoDaddy. Now my testing server is WAMP and it requires the ../ so I just do live test now in a password protected section (using sessions) on my server as it became a pain to keep changing that little detail on every page. Needless to say, though, aside from the white text on a white background my only assumption is that the address to the text file is not correct for whatever the reason. Be it the ../ or it needing an absolute path. On a side note however, the issue would also occur if for some reason the php folder is not permitting access. Just brain storming here. Perhaps an issue with the folder permissions or .htaccess restrictions?
  8. Nope, I'm serious. But I'm also still learning. I always figured there was a reason for it but I just remove the ../ and everything works as a result so I never looked into it. Ya know what, it also occurred to me that the server at my last college had the same issue. I had to remove the ../ on that server too.
  9. Not sure if this is the case here but I have encountered servers where adding a "../" in front of an address causes it to not work at all. You have: $info_test_file ="../php/info_test.txt" ; Just to test, try removing the ../ Like this: $info_test_file ="php/info_test.txt" ; I know it sounds silly but that actually matters on my GoDaddy server. It won't locate files if there is a ../ in front of addresses.
  10. I got it working. I had to add the javascript to an onload function. Turned out like this. <?php if(isset($_GET['vidhist'])){ ?> <script type="text/javascript"> onload = function() { create_window(<?php echo '"' . $_GET['vidhist'] . '"'; ?>,640,360); }; </script> <?php } ?>
  11. Alright, so I tried to set up the other page to create the popup when it loads if the GET variable is set. Unfortunately this did not work. Here is what I placed on the other page. if(isset($_GET['vidhist'])){ ?> <script type="text/javascript"> create_window(<?php echo $_GET['vidhist']; ?>,640,360); </script> <?php } ?> The javascript is not working when the page loads. It should create a pop up window.
  12. Greetings all, I have a bit of challenge that I don't know exactly how to solve. What I am trying to do is open a popup window using javascript and also redirect the page that has the original link on it to a new page. Basically what I want to happen is, user clicks on link, page redirects and a popup window opens at the same time. Sort of like having two links in one. Here's what I tried. It didn't work. echo ' <a href="sectvideo.php?sect=' . $row[0] . '"> ' . "<a href=\"javascript:create_window('".$row[1]."',640,360)\">" . ' <div id="historyUniqueWrap"> <div id="historyUniqueImage"> <img src="'. $row[2] .'"/> </div> <div id="historyUniqueTitleMessageWrap"> <div id="historyUniqueTitle"> <h4>Section: ' . $row[0] . " >>" . '</h4> <p>' . stripslashes($post1). "..." . '</p> </div> </div></a></a> Any ideas? Best Regards, Nightasy Edit: I just had an idea, I could set a condition to be met in the page that is being linked to using a GET. That would solve this issue. I'll try that and report back if it works or not.
  13. Well, apparently stripslashes solves this issue. Are there other ways besides stripslashes or preg_replace?
  14. Greetings all, I have a question about escaping characters prior to entering a field into a database and than echo'ing that escaped data back onto a page. My problem is that the slash marks are echo'ing out of the database onto another page. For instance if I were to do something along the lines of: $hpintrotitle = mysqli_real_escape_string($connect, trim($_POST['hpintrotitle'])); $q = "UPDATE homepage SET mstitle='$hpintrotitle' WHERE msid='1' LIMIT 1"; $r = @mysqli_query($connect, $q); If I place the word "You've" or "Isn't" into that field when I echo it out from the database it comes back as "You\'ve" or "Isn\'t" I know this is probably basic stuff but I apparently missed this lesson in school. Any help would be appreciated. Side note: I am bringing this data back as an array using something along these lines: $rowintro = mysqli_fetch_array ($rintro, MYSQLI_NUM); echo $rowintro[0]; echo $rowintro[1]; and so on.... Thanks for taking a look.
×
×
  • 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.