All Activity

This stream auto-updates   

  1. Past hour
  2. No, browsers send requests to the server, and the server sends a response back to the browser. The browser initiates the connection, not the server. The server just handles connections that get sent to it. You use ajax when you have a page that is already open and loaded, and you want to change some content on the page from the server without refreshing the entire page. You can see it on the forum when you submit a new post and it just adds it to the thread but doesn't refresh the entire page, it sends an ajax request to the server with the post content, the server responds with some sort of response that the Javascript is looking for (maybe HTML markup, maybe a JSON object, etc), and then the ajax callback function updates the page based on the server response. If it's on a separate domain that's going to be an issue, browsers block ajax requests to domains other than the originating domain for security reasons. The way to bypass that is to send the ajax request to a local PHP page, which will act as a proxy to send the request to the remote server, get the response, and send it back to the originating page. It's important to note in that case that the request to the remote server comes from the PHP server, not the user's browser. I'm still not clear on exactly what you're trying to do. It sounds like you just want a user to click a link on some other website, to your server. Like, a regular link like any other link on the internet, that goes to your server, and the user's browser loads the URL on your servers and sees whatever you want them to see. Just like any other link on any other website. Is it any different than that?
  3. Today
  4. OK. We appear to have touched base here: If you're saying the page isn't loaded by the browser yet, then nothing can happen until the browser sends a request for the page and gets a response from the server. So, I have to 1) Get the PHP page to send a request to the user's browser to open the host HTML page. 2) Force a request from the newly opened HTML page to the PHP page. 3) Receive the response and display it in the HTML page. This looks like AJAX. Something that I have never used before, but appears entirely within my reach as I have some knowledge of both Javascript and JSON. This appears to be something that I can do except for the fact that I do not know who the user is. Once again, The TASK The user clicks on a link on a third party website. An HTTP request is sent from the third party website to a PHP document hosted on my own webpage that uses the requested information to query a database and make a determination. But, how does the PHP document know where to send the HTTP request necessary to open the host HTML page in the user's browser? Roddy
  5. What are you, specifically, referring to here. Are you talking about using Javascript to load content via ajax? Are you talking about PHP getting data from a database, or sending a request to a remote server or something, and then using that data when it builds the response for the browser? I'm not sure why it's significant that the source is external, I assume by external you mean a remote server separate from the web server handling the request. If you're saying the page isn't loaded by the browser yet, then nothing can happen until the browser sends a request for the page and gets a response from the server. What other purposes? What's the main purpose of this page? Why not? I think we're beyond the discussion of abstract concepts and it's time to get specific.
  6. This should not be bring up 404 error, but you have missed a semi colon that will cause a php server error <?php $servername = "localhost"; $username = "root"; $password = ""; // Create connection $conn = new mysqli($servername, $username, $password); // Check connection if($conn ->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully"; ?>
  7. Let me try one more time. Usually, information from an external source is loaded into an HTML page that is already opened. In my case, the HTML page in which the information is to appear is not yet opened. What is more, the unopened page in which the processed information is to appear is used for several other purposes and cannot be easily produced from the processing PHP page that produces the information that is to appear in the HTML page. Roddy
  8. I am trying to find a solution to a problem that I have encountered while trying to get a fixed-top navigation menu to work dynamically in W3.CSS. By dynamically, I mean that the horizontally-orientated navigation bar should remain in its place under the page title and image until the page is scrolled downwards and reaches the top of the viewport. At this point, it should fix itself to the top of the screen. I have been able to achieve this effect using my own html/css and jquery script but this method doesn’t work as intended with W3.CSS. I have been moving my websites over to W3.CSS as I as a means of making them responsive and also because css is not my strong point and I like the W3.CSS structure. The menu bar operates as it should when it is in its static mode but, when it is fixed, which involves position:absolute and a z-index of 1, the dropdown menus no longer appear above the bar but are concealed within it. I have tried altering the z-index values of the dropdown-hover and dropdown-content elements but cannot find a solution to this problem. If there is anyone who can, I would be very grateful. The html code below is based closely on the “Navigation Bar with Dropdown” example taken from the W3.CSS Navigation Bars page. I also include the css used to fix the bar and the jquery function to call the css once the top of the screen is reached. HTML <div id=”container”> <div id=”header”></div> <img id="header_image" src="titleimage.jpg" alt="Header Image" class="header_image"/> <img id="header_image_m" src="title_image_m.jpg" alt="Header Image" class="header_image"/> <div id=”nav_bar_container> <div id=”nav_bar” class="w3-bar w3-light-grey"> <a href="#" class="w3-bar-item w3-button w3-mobile">Home</a> <a href="#" class="w3-bar-item w3-button w3-mobile">Link 1</a> <div class="w3-dropdown-hover"> <button class="w3-button">Dropdown</button> <div class="w3-dropdown-content w3-bar-block w3-card-4 w3-mobile"> <a href="#" class="w3-bar-item w3-button">Link 1</a> <a href="#" class="w3-bar-item w3-button">Link 2</a> <a href="#" class="w3-bar-item w3-button">Link 3</a> </div> </div> </div> </div> CSS #nav_bar_container, #nav_bar{ margin:0; padding:0; width:100%; max-width:948px; } .nav_bar_fixed { position:fixed; top:0px; z-index:1; } Jquery if ($( window ).width() > 600) { $(window).scroll(function() { var fixedBar = $('#nav_bar'), targetScroll = $('#nav_bar_container').position().top, currentScroll = $('html').scrollTop() || $('body').scrollTop(); fixedBar.toggleClass('nav_bar_fixed', currentScroll >= targetScroll); }); }
  9. If the server sends a 404 response that means it cannot find the file you are looking for. The contact.php file is not on the web server where you're looking for it, it doesn't have anything to do with the code in the file unless the server is configured to respond with a 404 for other errors for some reason.
  10. I'm just not sure what you mean by that. "Call a page", do you mean get the HTML contents of a page and do something with it? Are you saying you want to send an ajax request or something, get the response, and add it to the current page? That's possible.
  11. Show us the include statement that you use, and are all the php files together in one folder?
  12. So as to be simpler. QUESTION ONE: Is it possible to call a page into which the calling page is itself loaded? QUESTION TWO: If this is possible, there is likely more than one technique available to achieve the task. What are they?
  13. Here is the contact.php file: <?php $servername = "localhost"; $username = "root" $password = ""; // Create connection $conn = new mysqli($servername, $username, $password); // Check connection if($conn ->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully"; ?> Thanks
  14. This is a bit abstract, can you show your code and what you're trying to do? What do you mean by the host page?
  15. JSG: I have created a form page (sender.php) with a single input field. The value of this input field is sent via a $_GET superglobal to another page (receiver.php) that: one, retrieves all of the records from a data base; two, compares the value received from the form page (sender.php) with the values of a field of all of the retrieved records, and three, displays the receiver.php page with the value of another field of the same matched record. Everything up to this point has now been accomplished. JSG: Indeed, this is the part that I have yet to overcome. The displayed result (see above) is the information that should serve as a filler for another page that hosts all such form queries. QUESTION: How do I get the information from this filler (receiver.php) to appear in the host page with the host page when the result of the form query is sent to the filler template? Roddy
  16. That suggests it can't find that contact.php page, not that there is a database connection problem.
  17. Your question doesn't make any sense. Can the browser display the page?
  18. Please I have not been able to connect to MySQL. After opening a connect and checking the connection, I received the message: " 404 Not Found. The requested URL /contact.php was not found on this server. How do I go about this, I need help please. Thanks.
  19. Originally I thought it might have been a jQuery issue but this might make more sense in the CSS thread.
  20. Yesterday
  21. In your users table you should have a column called group or rang or whatever you want your admin to be named. After that you simply create a table called groups with your different ranks and functions, when you done that, you make sure that the id of the rang in the groups table match the id the user has in it's column. For example you make 2 different groups, Super User, and Moderator. Super User has the id of 1 and can access all administrative pages, in that case you make an IF condition between the Super User record's ID in the table and the user's ID in the column. The script will be something like this: if($_SESSION['user_rank'] == rank_required('page.php')) { //display page } else { //use a redirect method to a 404 not found or some kind of access restricted page } In the rank_required('page.php') will be a function that you will make and will check the rank's you've set for those pages, so that you make it a bit dynamically. But if you want an easy way, just set up it like: if($_SESSION['user_rank'] == 1) //in our case the super user { //display super user content } else { //display error or redirect } /* Also you can do something like this: */ if($_SESSION['user_rank'] == 1) { //display super user content } else if($_SESSION['user_rank'] == 2) //in our case the moderator rank { //display moderator content } else //in our case none of the above { //redirect page / error page } Easy enough, if you have any questions, feel free to ask, i personally didn't try the dynamically part as i never had a big website in which the dynamics would make a difference. But, in theory this should work pretty fine. I'm sure there are other methods out there. Oh, and for the rank_required('page.php'); function, never made a function like that, but i assume in order to work properly you will need to have another table in your database called page_ranks, in which will be a column with the name of the physical name of the page, the rank required (id from the groups table). After that it's all about if conditions with database record for that page. //Function function rank_required($page) { try { $sql = "SELECT * FROM pages_ranks WHERE page_name = :page"; //first we crate our sql to the database, we assume you already have a db connection $stmt = $db->prepare($sql); $stmt->bindParam(":page", $page); //now we bind the paramter in the sql with the variable from our function that we get from a page through basename() function; $stmt->execute(); $rowCount = $stmt->rowCount(); //warning as the rowCount(); function doesn't work if the previous statement that affected the db was an SELECT statement, but as long as you don't change records, i assume you will add all of your pages at one time, and then with the time the last sql statement would change, this should work just fine. if($rowCount > 0) { $row = $stmt->fetch(); //we fetch the result return $row['page_required_rank']; //this result will echo a value like: 1 or 2, depending on what id you have for your page in the page_required_rank collumn. Don't forget the ID depends on the group record's ID. And then this value will be compared into the header of the page with the $_SESSION['user_rank']; } else { return false; } } catch (PDOException $e) //catching possible errors { echo $e->getMessage(); } } But if you don't want to get complicated with all of this database stuff you can just use the define function and you can change the ranks whenever you want through the variables you defined, this will make a lot easier to work with grades, still, you will need to edit the user's column in the database. //Create a page like ranks.php and include it in everypage you need a rank system. //ranks.php define('SUPER_USER_RANK', '1'); define('MODERATOR', '2'); //page.php if($_SESSION['user_rank'] == SUPER_USER_RANK) { //display super user settings } else { //display error, redirect } //This helps you from later changing of the variable's value, so in that way you don't need to change the value from 1 to 2 or so on in everypage, you just have to change it in ranks.php to change the level of the required_rank. This is just a concept, to help you understand how this thing works, of course this is some basic php scripting, as i said before, i'm sure there are more complex and way efficient ways to do this, but if you're a beginner, this might help. It helped me in the past, and still helps me now. Hope i could help.
  22. You can post that stuff here.
  23. You could just use XAMPP as your default webbrowser, xampp comes with pre-installed mysql, php and apache server, and it also have a firezilla ftp server and the mercury mail server. Just look up on it.
  24. Hello, I'm a newbie developer and I'm just wondering if these forums would be an appropriate place to post the designs for a database I'm working on? I'm working on a site that people can use to keep track of their game collection. It's the first database I've designed entirely by myself and I'm looking for a place to post it so I can get some feedback on it. I see there's a thread for posting finished sites, is there a similar thread for databases? Thanks, Jay
  25. Like to the body tag? body{ overflow-x: hidden; } This seems to do the trick. Edit: Just wanted to clarify I had to also change .push-open from position:fixed; to position: absolute; Edit II: I also have to add a to .menu incase the menu height was taller then the window: .menu{ position: fixed; height: 100%; overflow-y: scroll; }
  26. How about setting overflow-x?
  27. Project Code: Project Description: I created a pretty basic push menu using jQuery. What I want to achieve is to click the menu bars, push the main-content over and display the menu. Then close the menu when you either click the menu bars again, click the close icon or click anywhere off the menu. So far I handled all of this successfully, however, one thing I don't like is if you scroll down on the main-content, then click the menu bars the main-content goes back to the top. It does this because I use toggleClass to change to 'position: fixed;' for main-content when the menu is open. I use position: fixed because if I use 'position: absolute;' for main-content instead I get horizontal scroll bars. I can't seem to find a simple solution to not have horizontal scroll bars AND not bring the main-content back to the top when the menu is open. It's not terrible with position: fixed; but I would like to gain an understanding or maybe achieve this a better way rather then settling. Note: Mind you my JavaScript & jQuery knowledge is pretty limited so there is probably a better way to handle this but here is where I am at and I'm open to any suggestions.
  28. myMethod just contains a string, it's not a function. It looks like you can use GetRef to get the function by name. e.g.: f = "OpenApplication" func = GetRef(f) func(url)
  1. Load more activity