xmodpt Posted August 1, 2009 Share Posted August 1, 2009 Hello all I have a user registration form working file and uploading an image (signature) to the database - ALL OK When i Log-in, i have if retrieving the session ID and showing the users "first name" - ALL OK now i need by using the same SESSION to also retrieve the user's image and show it in the same page. Can anyone help me with this ? this is my code <?phpsession_start();?><p><h1 class="style1">Welcome <?php echo $_SESSION['SESS_FIRST_NAME'];?></h1></p><p><h1 class="style1">Assinatura <img src="<?php echo $_SESSION['SESS_DATA']; ?>"></h1></p> My db has a FirstName field and a DATA field ( images ). `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `firstname` varchar(100) NOT NULL, `lastname` varchar(100) NOT NULL, `login` varchar(100) NOT NULL DEFAULT '', `passwd` varchar(32) NOT NULL DEFAULT '', `data` mediumblob NOT NULL, `image_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `ext` varchar( NOT NULL, PRIMARY KEY (`id`) USING BTREE With this code, it show the user's first name but no picture ... nothing Can anyone help me? Thank you all Link to comment https://forums.phpfreaks.com/topic/168439-sessions-img-help/ Share on other sites More sharing options...
ldougherty Posted August 1, 2009 Share Posted August 1, 2009 Information in the database does not automatically make it information in a session. The reason you are able to output the username with $_SESSION['SESS_FIRST_NAME'] is because you must be setting this somewhere in your code first. To take the image from the database and make it the image for that particular user on the session you would query the database to get the image path and then assign that image path as a session image variable. Hope that makes sense. Link to comment https://forums.phpfreaks.com/topic/168439-sessions-img-help/#findComment-888556 Share on other sites More sharing options...
xmodpt Posted August 2, 2009 Author Share Posted August 2, 2009 Thank you for the hint but my questions is, for someone that doesn't know much about this,... how do i do it... This all the code i have in the test page <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <p><h1 class="style1">Welcome <?php echo $_SESSION['SESS_FIRST_NAME'];?></h1> <p><h1 class="style1">Assinatura <img src="<?php echo $_SESSION['SESS_DATA']; ?>"></h1> <body> </body> </html> Thank you Link to comment https://forums.phpfreaks.com/topic/168439-sessions-img-help/#findComment-888817 Share on other sites More sharing options...
xmodpt Posted August 2, 2009 Author Share Posted August 2, 2009 Ok guys i have managed the retrive of the image from the DB but now it doesn't show as an image but as "strange" text: Welcome Nuno assinatura ?����mmm�M�[�ok�K�b�(�DDE�*������ � ��u,�>#|A�x�.!�=���9�v �s�[��_<.ӆ�f����A+�_$�h���%ks�x8���1��_u��O��R�#��{���U��#��I������� [��I����)�J��)o�&���= �rN;��i��H�(9c�� j�����>�e������S��5���O�H��e�ė��$�A;0w�0k��?g�����!��Hw���f;�#z:�F�(R�Y���1��?o�r���=�A�4x�X�Qc@8=מkќ���<�O�I3���U���������?�ɳ3���6R9����!�$�����Ҹ��?���]�ϋ�!:���[�c�҃�|XnV�fm�����A���F��S�äa�U�{m�L�z&�?�O�q��c��v����ƴ��$|E��>\���=Fd�Uh�i�����G�>� i have this code in the form: <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <p><h1 class="style1">Welcome <?php echo $_SESSION['SESS_FIRST_NAME'];?></h1> <body> <p>assinatura</p> <p> <img src="<?php echo $_SESSION['SESS_DATA']; ?>" alt="" name="image" id="image" /></p> </body> </html> Can anyone help this kid ;D Thank you Link to comment https://forums.phpfreaks.com/topic/168439-sessions-img-help/#findComment-888855 Share on other sites More sharing options...
xmodpt Posted August 2, 2009 Author Share Posted August 2, 2009 up Link to comment https://forums.phpfreaks.com/topic/168439-sessions-img-help/#findComment-888882 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.