hi I wrote php code

do.php

<?php session_start(); ob_start();
$salladim = $_SESSION['salla'];
$salladin =  isset($_GET['url'])?$_GET['url']:'' ;
 
if(!in_array($salladin,$salladim))
{
    header( 'refresh: 1; url='.$_SERVER['HTTP_REFERER'].'' );
echo '<h2>Hazirlaniyor...</h2>';
    exit();
}

file.php

<?php session_start();
function kodsalla($uzunluk) 
{
$karakterler = "0123456789"."ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$kod = "";
  while(strlen($kod) < $uzunluk) 
  {
    $kod .= substr($karakterler, (rand() % strlen($karakterler)), 1);
  }
  return($kod);
}
$kodsalla = kodsalla(8);

$_SESSION['salla'][] = $kodsalla;

When i run this code, i get the following error :

PHP Warning:  in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in /home/site/public_html/do.php on line 5

Its probably because $salladim is not an array (it is set to $_SESSION which might not be an array).

What is $_SESSION set to?

Indeed, $_SESSION is not an array, or it is empty.

$kodsalla; should take the value of $salla

var_dump($_SESSION['salla']);
array(1) {
  [0]=>
  string(8) "4AZWX25C"
}

Where did you put this var_dump? In file.php or do.php?

Where did you put this var_dump? In file.php or do.php?

file.php

Yes, I thought so. Put it in do.php after line 1.

woooow realy big error firefox locked

they appeared on the screen I tried to open the file

PK?>B4h%xd;abKs?r]/أlplLŁ`Ai:rqrrJ:F.7߇u:;tya))7FWz^ <dJ}r;<:g]a3d]%lrtQ5̜nJ-vK+LTkSsiEF8Z,صUj<K&E^c~]2&h06Obߌtq$WoLZ~Z96[bg

url line this

do.php?url=UPXG8UUM

EDIT:

this error from the setting ansi character.. fixed this utf8 without dom. but second-click on the link downloading do.php file not run this refresh function

if(!in_array($salladin,$salladim))
{
header( 'refresh: 1; url='.$_SERVER['HTTP_REFERER'].'' );
echo '<h2>Hazirlaniyor...</h2>';
exit();

hey mate!! the problem continues...

Try to do what I said last post?

do.php

<?php session_start(); ob_start();
var_dump($_SESSION['salla']);
$salladim = $_SESSION['salla'];
$salladin =  isset($_GET['url'])?$_GET['url']:'' ;

tray this code but second-click on the link downloading do.php refresh page null line seems

now also gives this error
wrong datatype for second argument in /home/public_html/do.php on line 6

You'll have to tell me what this var_dump says, of course. That's called debugging.

var_dump says NULL

Well, you'll have to figure out why. Did you call file.php before do.php?

yes so <a target="_blank" href="file.php?filename=a.zip">Download a file</a>

And what does that do other than creating a random string?

file.php

<?php session_start();
function kodsalla($uzunluk) 
{
$karakterler = "0123456789"."ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$kod = "";
  while(strlen($kod) < $uzunluk) 
  {
    $kod .= substr($karakterler, (rand() % strlen($karakterler)), 1);
  }
  return($kod);
}
$kodsalla = kodsalla(8);

$_SESSION['salla'][] = $kodsalla;
?>

Ah. Perhaps you'd like to include 'do.php'; ?

If not, where is do.php called? Perhaps you could provide a bit more information on what your logic is and how you thought it would work.

Which line add including in file.php

Well, you tell me, it's your program. But if you want to have it executed 'after' file.php, you could just put it at the end - before line 15.

file.php in

include 'do.php';

did not work, refresh the warning came into the loop... yes my script.. simple download php script... but I'm not very good at taking help people learn new..

Can't you just replace $salladim with $kodsalla in do.php?

Can't you just replace $salladim with $kodsalla in do.php?

worked :icon_razz: thank you but second click link refresh not work.. waiting for a long time, then coming down the 0 byte file named do.php

Be a bit more clear about what you want to happen, how you tried to do that, and what happened instead. I'm not going to write an entire application for you.

Be a bit more clear about what you want to happen, how you tried to do that, and what happened instead. I'm not going to write an entire application for you.

of course, my aim is just to learn and get help. I was wrong actually resolved the problem .. I thought the problem was solved within the cache read php I get the same error again

Yes, of course. Could you explain what exactly you're trying to do?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.