Jump to content

PHP && GET Method, sending variables?


newyear498

Recommended Posts

I have this script which I will post below.. the problem is that the following script only works with number..

 

when I use this script the error.txt will only write numbers and if I send text like... ?trueId=hey  nothing happens

 

but ?trueId=1 works just fine.. heres the script

 

 

<?php
$handle = fopen('error.txt', 'r+');
$trueId = $_GET[trueId];
$nextLine = false;
$realText = false;
while(!feof($handle) && $realText != $trueId)
  {
  $nextLine = fgets($handle);
  $realText = $nextLine + "\n";
  }
  
if($realText != $trueId){
$break = "\n";
$text = $trueId;
fwrite($handle, $break);
fwrite($handle, $text);
fclose($handle);
?>

 

THANK YOU! Appreciate the help!

Link to comment
Share on other sites

You should also have quotes around that array index. It will throw an undefined constant warning if you have your error reporting turned up high enough.

 

 

I never knew you were supposed to do quotes around that, I never really considered the GET/POST methods to be array indexs, good thing to know, appreciate it!!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.