Jump to content

R8kit

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Everything posted by R8kit

  1. Thank you very much. I inserted more data in the database and the code is working now. Thanks again.
  2. Hello everyone, I am new to MySQL and I am trying to insert the data type TEXT into the database but it isn't working out for me. I created an SQL file with the following code: CREATE DATABASE books; USE books; CREATE TABLE authors ( id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR (255), info TEXT ); INSERT INTO authors (name, info) values('Vivek', ' asdfkljasdkl;fjasd fasdl;kfjaskl;dfjasd fasdkl;fjasd;lkfjasdf asdl;fkajsd;lfkjasd;fsd fkl;asdjfaskl;djfsd sdakl;jasdl;kfjasdkl;fjasd asdkl;fjasdl;fkjasl;kfj '); I created an PHP page with the following code: <?php mysql_connect("localhost","root","passwd"); mysql_select_db("books"); $result=mysql_query("SELECT * FROM authors"); $row=mysql_fetch_array($result); while ($row=mysql_fetch_array($result)) { echo 'Name: '.$row{'name'}.'<br />'; echo 'Info: '.$row{'info'}.'<br />'; } ?> Can anyone help me insert and read the TEXT data type the proper way? Thanks in advance.
  3. Hey everyone, I am trying to secure php includes and I wrote the following lines: <?php $dir=scandir('.'); if (in_array('copyright.php',$dir)) { include('copyright.php'); } else { echo 'That page could not be found'; } ?> Is this code secure enough, can anyone help me improve it? Thanks in advance.
  4. Thanks for the replies. It's a little bit difficult for me to explain because my English is not 100% I thought if the session variable: [ if (isset($_SESSION['exists'])) ] is not set, the else "lines" would be executed. And in the else statement I assigned $_SERVER['HTTP_USER_AGENT'] to $agent, and stored a value in the session, so I thought that when you refresh the web page the session will exist and the [ if (isset($_SESSION['exists'])) ] condition will be true and the lines below them will be executed and check if the same HTTP_USER_AGENT is being used. In other words I thought that I already assigned a value to $agent in the else condition and that it would stay in memory somewhere so I can compare it to the current HTTP_USER_AGENT being used, and if it did not match destroy the current id session and generate another one. But I think I understand what you mean, it indeed came out of nowhere. I thought it didn't matter because the condition will not be true anyway and jump to else and execute the lines there and store the $agent variable. I thought the next time the code executes[Refresh], the condition would be true and the HTTP_USER_AGENT compared. I hope you understand what I am trying to say.
  5. Hey everyone, I am new to PHP and I want to learn how to secure a PHP session properly. I wrote a few lines, but I don't know if it's secure enough. <?php session_start(); if (isset($_SESSION['exists'])) { if ($agent != $_SERVER['HTTP_USER_AGENT']) { session_unset(); session_destroy(); session_regenerate_id(True); } } else { $_SESSION['exists']=1; $agent=$_SERVER['HTTP_USER_AGENT']; session_regenerate_id(); } ?> Can anybody help me correct or improve my code? Thanks in advance.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.