I have a form page where the users must put a code that I send them by email, this form has as action file redirect.php, which contain this code:

```
<?php
header('Location: page.php?code='.$_POST['code']);
?>

```

now what I want to do with my form page is to show a error or to redirect to a page if the code they input on my form doesn's exist in code.txt file.

Is it possible that? And if is it how to do it?

**EDIT:** 

I think that must be easier: I want that this form:

```
<form action="page.php" method="post">
<input id="code" name="code" type="text" />
<input type="submit" value="Submit"/>
</form>

```

I want this form to pass to the page.php only if the value of input id="code" match values from code.txt
['https://Stackoverflow.com/questions/20132066', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3016012/']
I'm reqesting a image from yahoo and it isn't using the `content-disposition` header but I am extracting the `date` and `content-type` headers to construct a filename. This seems close enough to what you're trying to do...

```
var request = require('request'),
fs = require('fs');

var url2 = 'http://l4.yimg.com/nn/fp/rsz/112113/images/smush/aaroncarter_635x250_1385060042.jpg';

var r = request(url2);

r.on('response',  function (res) {
  res.pipe(fs.createWriteStream('./' + res.headers.date + '.' + res.headers['content-type'].split('/')[1]));

});

```

Ignore my image choice please :)
Question has been around a while, but I today faced the same problem and solved it differently:

```
var Request = require( 'request' ),
    Fs = require( 'fs' );

// RegExp to extract the filename from Content-Disposition
var regexp = /filename=\"(.*)\"/gi;

// initiate the download
var req = Request.get( 'url.to/somewhere' )
                 .on( 'response', function( res ){

                    // extract filename
                    var filename = regexp.exec( res.headers['content-disposition'] )[1];

                    // create file write stream
                    var fws = Fs.createWriteStream( '/some/path/' + filename );

                    // setup piping
                    res.pipe( fws );

                    res.on( 'end', function(){
                      // go on with processing
                    });
                 });

```