All you have to do to maintain a session is start it before you call any variables. Once you've started the session, you can store variables for use in later scripts.
Beware though, once the user closes the browser, the sessions' over.
I'd use the following
SCRIPT 1:
<?php
// Start session
session_start();
// Set some variables (this simulates form input)
$_SESSION['answers']['Q1'] = 18;
$_SESSION['answers']['Q2'] = 36;
$_SESSION['answers']['Q4'] = "Fred";
?>
=============================
Hope that helps...
Sessions in PHP are easy to learn and set up, first of all you need to make sure you use the function session_start() at the start of each script to make sure the sessions work. Then all you need to do is the following to store information in sessions: <?php // allow sessions to work on script session_start(); // set up a session called my number $_SESSION['my_number'] = 1; ?> That's all you need to do to set up and store data in a session. Now if you want to delete a session you will need to use the unset() function like shown below: <?php unset($_SESSION['my_number']); ?> To destroy all sessions in one go you can call the session_destroy() function. This will save you some time. <?php session_destroy(); ?>
A PHP session serves quite a few purposes. PHP sessions store data that the web application developer would like to have preserved across the different page loads.
A PHP session is a concept where specific variables (and their respective values) are carried throughout a user's viewing of a PHP-driven website. These sessions can be initialized and continued using the session_start() function. The session values are stored in the $_SESSION global variable. For more information, see the php.net documentation of session functions.
Parse error in PHP means that your script is invalid - it is not compliant with the programming language specification. After parse error script is no longer executed.
To delay a script in seconds you would use the sleep() function as shown below: <?php echo "hello"; sleep(5); // delays the script for 5 seconds echo "finished"; ?>
A php script can only be executed within a Web server that runs php.
You can use phpMailer() Or, you can use mail() PHP function to send emails via PHP script.
Open the PHP script and delete the PHP from it.
To create a PHP script all you have to do is create a new file, then save the file as "filename.php". It must have a .php file extension.After that open the file and put in the PHP tags like shown.Then you write your PHP script within those tags and upload to your web space and check it out.
2 Methods: 1. You execute your php binary (in linux, make sure you have php-cli installed) and pass the script as an argument. EG ($: /usr/bin/php /home/user/script.php) 2. A sh'bang in the first line of your script, with the full path of your php executable: #!/usr/bin/php -q <?php ScriptStuff(); ?>
If you created a PHP script that could provide that for people then yes you could.
You can't use PHP in an HTML document, but you can use HTML in PHP script.
PHP is related with HTML. HTML can be included into PHP script as well as PHP script can be included into HTML code. PHP begins and ends with <?php ?>. PHP is mix of few languages so semantics is mixed too.
Sessions in PHP are easy to learn and set up, first of all you need to make sure you use the function session_start() at the start of each script to make sure the sessions work. Then all you need to do is the following to store information in sessions: <?php // allow sessions to work on script session_start(); // set up a session called my number $_SESSION['my_number'] = 1; ?> That's all you need to do to set up and store data in a session. Now if you want to delete a session you will need to use the unset() function like shown below: <?php unset($_SESSION['my_number']); ?> To destroy all sessions in one go you can call the session_destroy() function. This will save you some time. <?php session_destroy(); ?>
The preferred way is to simply alter the session superglobal. <?php $_SESSION['variable'] = "value"; ?>
A PHP session serves quite a few purposes. PHP sessions store data that the web application developer would like to have preserved across the different page loads.
A PHP session is a concept where specific variables (and their respective values) are carried throughout a user's viewing of a PHP-driven website. These sessions can be initialized and continued using the session_start() function. The session values are stored in the $_SESSION global variable. For more information, see the php.net documentation of session functions.