-1

do you have any suggestions with my problem. I need to use $_GET and $_POST at the same time. $_GET because I need to get the row which the user want to save I commit the row through the url. $_POST because I need to write the changed input into a csv file. It looks like this:

$fileName = '../anfragen.csv';
$lineNum = $_GET['row'];
$arr = file($fileName);
$lineToEdit = $lineNum;

if($_GET['speichern'] != NULL ) {
    $handle = fopen ("../anfragen.csv", "w");
    $arr[$lineToEdit] = utf8_decode($_POST['email']) . ";" . $_POST['gender'] . ";" . "\n");

    // write the array in the csv file
    foreach($arr as $line) {
        fwrite($handle,$line);
    }
}
Timothy
  • 3
  • 2
  • And what is the problem? Besides the fact you have to make a POST HTTP Request to this page with a url markup like page.php?row=1 – Allmighty Oct 28 '14 at 10:38
  • And what is the issue? You can use $_GET and $_POST at the same time because you can send an post request to a url with $_GET parameters eg. http://www.domain.com/index.php?id=10 – andreashager Oct 28 '14 at 10:39
  • I don't think you can `GET` and `POST` on the same request. – Savv Oct 28 '14 at 10:39

2 Answers2

0

Use $_REQUEST to have $_GET and $_POST variables in one array.

Justinas
  • 37,569
  • 4
  • 61
  • 88
  • There is some use to close vote against existing question for this Q&A website. Just telling. – hakre Oct 28 '14 at 10:40
0

Use $_REQUEST instead of $_GET and $_POST.

fredtantini
  • 14,608
  • 7
  • 46
  • 54
Tristup
  • 3,498
  • 1
  • 12
  • 26