Welcome! Log In Create A New Profile

Advanced

Topic 5C

Posted by Anonymous User 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Anonymous User
Topic 5C
January 16, 2006 08:19AM
This is the thread for problems/comments related to Topic 5C.
Re: Topic 5C
April 25, 2006 08:24AM
The system variable SID is empty. I have also try to use session_id(), but this is a long number. The session was started with session_start(). Any idea how I can get the SID value? sad smiley
Re: Topic 5C
April 28, 2006 08:22AM
Having the same problem as Miekie. Nothing I am sure a little thought and stress won't solve. Might be something to do with my php.ini file.
Re: Topic 5C
May 04, 2006 10:59PM
Instead of SID I use session_id() and put a session_start() on first line of my code. Now there is no need for the session_register["bgcolor"], instead I retrieve the value with $_SESSION["bgcolor"].

Topic completed.
Re: Topic 5C
May 05, 2006 12:50AM
After checking my php.ini file, my browser settings, reading manuals, and doing session tutorials I found through Google, I have managed to complete this topic.

Google is great, but it can also add to the confusion sometimes. I came across different ways that programmers work with sessions, depending on the settings in your php.ini file, and the version of PHP that you are working with.

I have come to the conclusion that we must solve these problems within the scope of what we know, and not try to complicate our lives with coding that we will eventually come to master through experience.

If I ever have a problem with Sessions again, I am going to be bitterly disappointed in myself.

Caio
Re: Topic 5C
May 05, 2006 01:53AM
Done.

Turning register_globals on in php.ini and using session_register() is not adviced by the php community. Using $_SESSION is a more secure way of doing things as Miekie is doing. There are some exploits that take advantage of register globals being on.


Murphy's Technology Law 7
-- The attention span of a computer
is only as long as its electrical cord.
Re: Topic 5C
May 07, 2006 10:05PM
Har!

Done. Also did the whole Lesson 6 Bring on the project!!!



Re: Topic 5C
May 11, 2006 03:12PM
I have completed this topic
Re: Topic 5C
May 15, 2006 08:05AM
Completed the topic
Re: Topic 5C
May 15, 2006 03:12PM
OK
I do not seem to be able to get $bgcolor to be assigned a value from the radio buttons

I have changed the if empty color to Red so I know that the $bgcolor remains empty.
I have tried Miekie code but still get errors

output is

Warning: open(/tmp\sess_df0a6d65b6e08b7ad6539d0478807303, O_RDWR) failed: No such file or directory (2) in C:\FoxServ\www\StudentPHP\session.php on line 2

Select a background color
Yellow
Blue
Silver
Beige


refresh page, Don't change background color

To other page
Warning: open(/tmp\sess_df0a6d65b6e08b7ad6539d0478807303, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0


my code is

session2

<?php
$_SESSION["bgcolor"];
//session_register ("bgcolor"winking smiley;

if (empty($bgcolor)) {
$bgcolor = "Red";
}
?>

<html>
<head><title> Session Example</title></head>
<body bgcolor='<?php echo $bgcolor; ?>'>

What color is my background?

<a href = 'session.php?<?php echo SID;?>'> <br><br>Back to form page</a>
</body>
</html>


session
<?php
session_start();
//session_start("bgcolor"winking smiley;
$_SESSION["bgcolor"];
//session_register ("bgcolor"winking smiley;

if (isset($color)){

switch ($color) {
case "Yellow":
$bgcolor="#FFCC00";
break;
case "Blue":
$bgcolor="#4682B4";
break;
case "Silver":
$bgcolor="#C0C0C0";
break;
case "Beige":
$bgcolor="#FFE4C4";
break;
default:
$bgcolor = "white";
break;
} //end switch
}
if (empty ($bgcolor)){
$bgcolor = "Red";
}
?>

<html>
<head><title>Session Example</title></head>
<body bgcolor = '<?php echo $bgcolor; ?>'>

<form method = 'GET' action = 'session.php?<?php echo session_id();?>'>

Select a background color
<br>
<input name='color' TYPE='radio' VALUE='Yellow'> Yellow
<br>
<input name='color' TYPE='radio' VALUE='Blue'> Blue
<br>
<input name='color' TYPE='radio' VALUE='Silver'> Silver
<br>
<input name='color' TYPE='radio' VALUE='Beige'> Beige
<br>
<br>
<input type='submit'value ='Change background color'>
</form>

<a href='session.php?<?php echo session_id();?>'> refresh page, Don't change background color</a>
<br><br>
<a href ='session2.php?<?php echo session_id();?>'>To other page</a>


</body>
</html>

Sorry, you do not have permission to post/reply in this forum.