Advanced Session Script [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Improve this question
I was wondering if anybody knows how to make a script that would essentially save a percentage of how much you completed of say a test or something and when you go back to continue it will bring you to the page you're at. For example theres 5 pages, and you're on page 3 so it'll save as 60% and whenever you click continue it brings you to that page.
When I say advanced I mean like secure so you can't go skip to page 5 just by putting the url. For example at the head of each test page I would put this
if (session > 60%) {
header(Location: page3);
}
Do you guys know what I mean?
I was hoping somebody could just help me do this somehow and make it so it saves under the users profile and you can call the percentage whenever using a variable. Any ideas?

You're pretty close. First, check out any PHP Session Tutrorial to learn about them a bit.
You can access session variables with $_SESSION['keyname'] (after you've called session_start() on your page.
Simply save your progress as one of these, e.g. $_SESSION['progress'] = 60;
and evaluate by testing if the session is set (so you don't get an error), and then evaluate it as follows:
if ( isset($_SESSION['progress']) )
{
//write your if (or switch) statement here
}
Let me know if that makes sense or if you have any questions :)

Related

How do I check for a mysql database change without refresh? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to be able to have my main page (index.php) check every 10 seconds for a change in the mysql database table 'refresh'. If the 'refresh' value is 1 it needs to refresh the page in its entirety. If the value is zero it does nothing. I would use meta-refresh but I cannot have the page always refreshing as the page has a slider and it would mess up the rotation. Please let me know what you think of! Thanks in advance!
Use AJAX to check if an update is required.
http://api.jquery.com/jQuery.ajax/
You should learn the basic how to's of AJAX before using something like jQuery when you don't even know what's going on.

How do I get information from this page, that isn't in the HTML code [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
http://www.aliexpress.com/item/NEW-7-Android-2-3-256MB-DDR2-4GB-NAND-Flash-7-inch-tablet-pc/498159194.html - I got this link
Here you can see a buttons: bundle, color
If you click some of them the price will change, but the question is how can I parse that behaviour to my page via php?
The problem is that I can't understand where is javascript code that executes this, or how to find it, maybe someone got ideas about that?
Inspecting that page's source code I can see that the skuProducts variable in javascript contains this information encoded into a JSON-string. You can't really run this javascript code on your webserver, so you'll have to devise another way to get that variable's value - and then you can use json_decode() to get the contents.
Note that changing the amount of items results in an AJAX call to a shipping costs calculator. You could probably simulate that, but I'm not sure that webshop would like that (and it might be illegal).

Get the source code of a web page after it has been modified by jquery in php [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
here is an example, say every item in each list was clicked on http://katproxy.com/the-big-bang-theory-tv8511/, how would you proceed to get the source code of the modified web page using php considering the fact that the url has not changed (file_get_contents is probably out of the question).
Thank you!
Using PHP? You can't, not without fetching the page source and evaluating its JavaScript, which is obviously quite impractical.
The "page" hasn't change, only your in-browser representation of the DOM has been modified. You would need PHP to talk to your browser, and ask for the state of its DOM, not the remote server, which cannot possibly serve up the HTML representation of your browser's current DOM.

Q&A Forum - Logic [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm not asking for help with coding I'm just asking for somebody to help me come up with an idea of how I would make it.
Basically I want to make a basic Q&A forum, I guess you could say its like Stackoverflow, but not nearly as advanced its just something quick to add onto my website.
I was thinking of just making a default form you fill out to post what you want then it'll just save the POST of all the data into a table in a database and it'll give it an auto_incremented ID. The only thing I can't think of is how I would display all of them on the homepage, make it so it only displays a maximum of 15 posts and then make different pages like Page1,2,3,etc...
Should I check the table for how many rows there are and then save that amount as a variable then make it post them in order from what ID they have? I'm not sure what I could do for comments and everything but I would love your guys help with figuring this out!
As I said this isn't really much about the coding, its more about figuring out the logic behind how I would make it.
What your asking about is termed pagination here's a php tutorial
http://net.tutsplus.com/tutorials/php/how-to-paginate-data-with-php/

counting the number of times a script is executed [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have got two php forms - question.php and marks.php. I want that each time question.php submits its values to marks.php , the variable $total in the form marks.php be incremented. I have tried using static variable but still am not able to get it done!
Nothing "inside PHP" itself will persist anything across different page loads. You need to store the value somewhere "external", e.g.:
write it to a file
write it to a database
store it in a memcache or other kind of cache
send it to yourself in an email
burn it into the screen of the computer and use an elaborate video camera and OCR setup to read it back
...
maybe: sessions

Categories