Open newly created webpage in php - php

I want to create a new webpage using php. Then after I create the page I would like to open the page in a browser. I have the create part (create file) down and the delete file, but how do I (can I?) open the webpage from my php created page that has confirmation message?
To clarify, I have created an html page that asks the user to enter information to create a web page. I ask the name of the webpage, extension type, and a text box for content. I then give them 3 buttons - Create page, view page, delete page. If the user selects Create, I then run a php page that creates the file for the webpage and displays a message that the web page was created.
So, my question is how do I either return to the html page to allow the user to select view webpage(which does not require php) or to allow the user to select to view the webpage from the "Confirmation" page which is php?
Thanks,
Jason

You can alter the header file to do this, and some people may suggest this, but I've found that this causes issues without knowing more code that's been written before or afterwards.
I recommend that you use JavaScript to change the location of the page and simply place an "onclick" or "onsubmit" call to the below function on the button that creates the page.
<script>
function createAndRedirect(){
var x = document.getElementById("#idOfInputWhereWebPageIsSet");
var y = x.value;
// You can add an alter confirmation message here.
// alert("Web Page Created!"); Remove the comment slashes for a basic confirmation alert.
location.replace(y);
}
</script>

Related

I want to click on link and not go to other html page but echo a page. Is that posible in php

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

How to disable Script on certain selected page

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.

Open jQuery dialog from previous page

This may sound vague, I apologise for that. But I can't seem to find anything or anyone that's trying to do the same as me.
Although, I've just seen How to trigger open a jQuery UI dialog from a separate page? but I'm not sure that would strictly work.
I have a single profile page for members with the data driven by an XML feed. On the profile page is a link that opens a jQuery dialog box. This is working fine.
Elsewhere on the site, is another page that generates a list of members depending on a filter, with a link to that users profile. Also on this other page, with the list of members, is a duplicate link to the jQuery dialog box.
How can I make this duplicate link go to the profile page and automatically fire the jQuery dialog box to open?
My way to do this is to use Hash part of URL
for example your URL to profile from other page should be like this
profile#showdlg
and in profile page
var hash = window.location.hash.substr(1);
if(hash == "showdlg"){
//Show dialog here
}
And this should do the trick
You cannot (should not) directly trigger some script action in a page "to be loaded in future". Instead the trigger should be part of the page itself.
So if that profile page is generated in a dynamical way an approach would be to implement a conditional feature that adds such trigger (like using jquery to fire the dialog when the dom tree is ready, there are millions of examples for that). The condition would be whether the profile page has been called via such a special reference or not. You could detect that by looking at the HTTP-REFERER. So it boils down to: if called in a specific way, then add a 2-lines-of-code trigger to the profile page that initially fires the dialog.
To answer your comment below here some more detailed description:
There is not much coding involved. The links reference the users profile pages. The profile pages are generated by php I assume. So all you need to add is one detail: inside php check if the request currently processed has a certain referer it was raised from:
<?php .... if ('other_page.php'==$_SERVER[HTTP_REFERER]) { ... } ... ?>
If so you know that the profile page was called from that other page instead of the normal situation, so you want the UI dialog to fire by itself. For this you add a tiny javascript to the generated page which does the trick as soon as the page has loaded:
<script>$(document).ready(function(){$('#mydialog').raise();})</script>
The details obviously depend on what type of dialog and how it is raised. But you should get the idea of what I suggest...

Open messages in popup window - PHP

I want something like when you click on image on facebook, url changes to facebook.com/photo.php?.... but without redirect. I want exactly the same thing but to open the messages, not photos. Simply, i want when user clicks on displayed messages with other users to open a new popup window without redirecting to new page with all messages with that user. Is that possible and if it is please tell me how to do that.
Example:
Messages with user A
Messages with user B
Messages with user C
And when user clicks on 'Messages with user B', it will open new popup window with all messages with that user, and of course, pulled from database.
I decided to write this as an answer since it is too long for a comment.
To "properly" set up what you want, you need several parts working together:
AJAX: (eg: jQuery.ajax) Retrieve data from the server programmatically with javascript
CSS/HTML dialog: (eg: jQueryUI dialog) Create a fake popup inside your page, usually to give the content some prominence
History State: (eg: SO Q/A) Change the page URL (in addressbar) without reloading the page.
I think I understand what you are looking for!
Use case scenario:
1- User looks at a feed of posts/images/anything.
2- User clicks on one of those posts and, it opens in a box with that same content.
The thing you are looking for is called "Lightbox" or "FancyBox".
I googled and found a few examples:
http://fancyapps.com/fancybox/
http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/
http://lokeshdhakar.com/projects/lightbox/
you basically need to recreate the loop or make on a onclick function when user chooses the photo, and just call the index of that photo again inside the lightbox.

Show once popup

Say I wanted to create a popup for my website that only showed once (if the user either filled it out or clicked the "do not display again" button), how would I do so. I am creating the popup and form using javascript and html, passing it in php to a database.
The easiest way would be to use a cookie which would be downloaded to the client's computer. When your webpage loaded, it would need to check for this cookie, and if not found, or a flag inside it had a property "noPopup=true" for instance, not display the popup.

Categories