I have a PHP include file which contains a lot of user actions i.e. login, logout, toolbars, buttons etc. This file is the same across the entire site hence the include. Inside the include I have jQuery scripts which call other files to validate a user login, log them out, user menus etc. This include is the entire header of the site.
Now I want to reload this include after say a user logs into the site but I do not want to reload the entire page and they could be performing action which I dont want them to lose or I dont want them to be stored as cookies/sessions.
There is a container div (#dynamicHeader for for example) which holds the include.
I have tried the .load() from within the include but that does nothing. I know the content is being replaced correctly as I have tried .html("logged in") and the container div displays this. Does anyone know a way to reload the include from within the include?
Many thanks
You could use $.get() Documentation Here. You would call the page to be included here and set the html of #dynamicHeader to the returned html in the callback.
Related
I have a page that has a few php include functions, pulling in content from external php files to represent on the page. Like so:
<?php
include 'htmlblocks/catalog.php';
?>
What I am looking for is a way to reload one of those include functions when a button is clicked.
Is this possible and if so how would I go about doing this?
*The end goal is to have this specific file (the one that is included via php) take parameters from the url to use to select data in a SQL database *
Thanks in advance!
How can I use php to echo a page instead of linking to existing html page with hyperlink?
One example would be
<html>
<body>
click on this link to go back
</body>
</html>
Now, I don't want this link above to be a link to html page but to echo a page with php code when user clicks on click on this link to go back(to generate a page). This way, nobody can access a page after they logout.
Can php do this?
If someone logged out of your website or application I assume you will have a check whether or not this person is allowed to view the content.
Your question itself is very unclear to me. But it sound a bit if you want to do client-side coding (don't follow a link when it's clicked) with PHP which is not possible since PHP is a server side language. You will need Javascript to change the behavior of a link (for example, make an AJAX request which returns the content of another page).
Create a function, what the function should do is it should get triggered on a button click event and the code inside the function must send an curl request to the url you want and get back the html from it and echo it on your page
For answering the second part of your question!. you want no one to access the data without logging in so maintain $_SERVER['']; and sessions for users and validate if the user is inside a genuine session then show him content else no
1st of all, its not Wordpress. Just PHP and HTML.
Is there any way to disable a few script on selected pages? I've saved all my custom script codes on scripts.js and serving it to all the pages in my site.
What I'm facing is conflicting issue. i.e. Login js code is having some issue with search js code.
I've searched all over the net but unable to find a solution. All I'm getting is for Wordpress with wp_enqueue. Is there any way to something like that? I mean disabling some script on selected pages?
jquery codes: http://pastebin.com/63eGKkCc
Its common problem if are using duplicate ids in different scripts.
For egs, if you are using name as id in login script and the same id is used in search script, so definately these 2 would create conflits with the same id name
Now, to reslove this you can have 2 options
Add unique ids to elements or access by using its parent selector like $('#parent_unique_id #name')
Add login script only to login page and search script to search page.
Updated, if you want to check the page and then add/run script then you can use location.href like,
if(location.href.indexOf('login')!==-1) { // for example its login.php page
// code for login page
}
And do something like for search page.
I currently have a site I built using jquery/php/PDO/mysql.
I use classes for most functions, including database, logins, content, etc...
I am wanting to change my forms over to jquery's ajax calls. But there's where my problems start. With the ajax call, I can't call a php function in the ajax post url. Heres the heirarchy Im using;
->content.php (form resides in a function named content.)
->process.php (post checks and then a call to add content from class)
->class.content.php (insert vars into db)
Once form is submitted, it goes to process.php which contains checks and then a class call to add content.
While this hierarchy seems to be the most used for ajax, it causes path issues. It breaks my db connection, my config connection, etc...
All I really want is to add ajax forms. But I don't want to rewrite my whole site. Any suggestions?
It sounds like process.php was previously included in content.php but now you're trying to submit to it directly. However, process.php was dependant upon the configuration variables, database connection etc. which was included in content.php and accessible by being included within that page.
I think you need to make a new page which includes the same other files and has the same initialisation code as content.php, except it doesn't output the form and instead just includes process.php, then submit to the new page.
Hard to say for sure without code though.
I have a profile page where im showing the friends of that user from db, I'm using auto scroller that works fine if I place that data directly in main file not an external file, Also I have a drop down that on selection will sort the friends records accordingly, but as I have moved the code to main file, I need to make ajax call to same file not an external, to repopulate data with required sorting.
Please let me know how can i do this on same file with ajax. On selection of drop down value.
Have you considered using Jquery?
Its surprisingly easy. You just need to do $('#contentdiv').load('contentyouwant') where you bind the event for the ddl.
If you must use the same file, place the code that will be ran by ajax, in a function. then at the beginning of the page, evaluate if this was the ajax call or the whole file.
Hope it helps.