Adding vars to post? (solved)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wesnoel
Forum Commoner
Posts: 58
Joined: Fri Sep 05, 2003 11:53 am

Adding vars to post? (solved)

Post by wesnoel »

Greeting everyone ! :D

I am submitting from a form to a script that writes a siple csv file. ( easy ).

but....

I need to add variables to the file that are not sent from the form. for security I can't add them in a hidden. so my question is, how do I add variables after the form has been submited?

The I am using is:

Code: Select all

<?php
// Write to File


$string='$coname,$contact,$phone,$state,$qty,$reprogrammed,$teletraining,$terminal_aps,$yes_no,$if_yes,$initials,$date,$address,$repname,$status';


$filename = \"files/$repname.$coname\";

//echo\"$filename\";

if(file_exists($filename . \".csv\")) {
    
    echo \"<meta http-equiv=\"refresh\" content=\"0;URL=error.php\">\";
    //break;
} else {

$myVars = split (\",\", $string); 

foreach ($myVars as $str){
$newString .= \",\" . @$_POST[substr(\"$str\", 1)];

$newString=stripslashes($newString); 
$newString= strtoupper($newString);
}

$file = \"files/$repname.$coname.csv\";
$fp = fopen(\"$file\",\"a+\") or die (\"Issues\");


fputs($fp, $newString); 



fclose($fp);


?>


If anyone could help I would greatly apreciate it.

Wes/
Last edited by wesnoel on Sun Jul 31, 2005 4:10 pm, edited 1 time in total.
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post by Straterra »

Perhaps..encrypt the data and put it into a cookie or session?
wesnoel
Forum Commoner
Posts: 58
Joined: Fri Sep 05, 2003 11:53 am

Post by wesnoel »

Well I figure adding to post after the fact would not be to hard or somehow adding to $newString or something like that. It is just writing to a csv so it shouldn't be to hard to do . I just do not know how.

Any other suggestions?

Wes/
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Can't you just include any extra variables in the page that the form is sent to?
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Are you validating the submitted form data? That's the first step. You need to clean the data of anything nasty and check that required POST keys are set - if not redisplay the form.

If all the $_POST vars you need are set just get the other stuff you need to write to the file from wherever it is stored - what exactly is the problem you're having there?
Post Reply