Need Simple Help

I’m no PHP whiz, so I need help, now please dont say it has been discussed before coz i’m going crazy looking for it on google… Ok heres the problem

I have a HTML form (Call Tracker) at work, I want to write data from that form to a text file, appending it,

i dont have the exact code but you guys know how a form is so this is what i wrote at home, picked random bits from tutorials

[hr]

Untitled Document First name:
Last name: <?php $myFile = "testFile.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); $stringData = $_GET['firstname'] + "\n"; fwrite($fh, $stringData); $stringData = $_GET['lastname'] + "\n"; fwrite($fh, $stringData); fclose($fh); ?>

[hr]

something is just not working right plz help me, if I get to know how to fix this then i think i can handle the one in my office

You aren’t checking to see if the submit button has been clicked in your php code.

I am no whiz either but I think you need something like

[php]

<?php if (isset($_POST['Submit'])) { $myFile = "testFile.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); $stringData = $_GET['firstname'] + "\n"; fwrite($fh, $stringData); $stringData = $_GET['lastname'] + "\n"; fwrite($fh, $stringData); fclose($fh); } ?>

[/php]

I haven’t checked your file write code just answered your question.

You should also be sanitising the input to ensure that no malicious code is sent in with the response.

thanks for ur time mate, but i found a better alternative in js

Sponsor our Newsletter | Privacy Policy | Terms of Service