chosendesigns Posted April 29, 2008 Share Posted April 29, 2008 Hi there, A quick question... Is it possible to make a simple calculation in PHP and then output the answer of this to a seperate PHP file? very simply... $sqlusernamecheck = "SELECT " . "username" . " FROM" . " bbcusers" . " WHERE" . " username" . " =" . " '$username'"; $usernamecheck = mysql_query($sqlusernamecheck, $cxn); $usernameif = (mysql_num_rows($usernamecheck)); I would like the above output of the $usernameif variable (which should be 1 or 0) to be outputted to a seperate PHP file... Is this possible and if so how?? Link to comment https://forums.phpfreaks.com/topic/103389-outputting-a-result-to-another-php-file/ Share on other sites More sharing options...
farkewie Posted April 29, 2008 Share Posted April 29, 2008 what about this? <?php header ("Location:otherfile.php?unameif=" . $unameif); ?> Link to comment https://forums.phpfreaks.com/topic/103389-outputting-a-result-to-another-php-file/#findComment-529496 Share on other sites More sharing options...
chosendesigns Posted April 29, 2008 Author Share Posted April 29, 2008 Do I post that code into the new file linking to my registration form or vice versa? I want the results of $usernameif to be stored on my server in a txt document or php file so I can read the results in Flash easily... Link to comment https://forums.phpfreaks.com/topic/103389-outputting-a-result-to-another-php-file/#findComment-529548 Share on other sites More sharing options...
farkewie Posted April 29, 2008 Share Posted April 29, 2008 Ok, Well in that case you would probably want to set a cookie. and just create a php file that reads the cookie and links to flash. <?php $sqlusernamecheck = "SELECT " . "username" . " FROM" . " bbcusers" . " WHERE" . " username" . " =" . " '$username'"; $usernamecheck = mysql_query($sqlusernamecheck, $cxn); $usernameif = (mysql_num_rows($usernamecheck)); setcookie("userbaneif",$usernameif,36000); ?> That code may be slightly wrong. http://php.net/setcookie Link to comment https://forums.phpfreaks.com/topic/103389-outputting-a-result-to-another-php-file/#findComment-529920 Share on other sites More sharing options...
Fadion Posted April 30, 2008 Share Posted April 30, 2008 Been ages since i dont work with flash, but guess the cookie example gave by farkewie will work (if the timestamp was set correctly). For a file approach, u can write a txt file with php and read the variable with flash (with loadVars() if im correct): <?php $sqlusernamecheck = "SELECT " . "username" . " FROM" . " bbcusers" . " WHERE" . " username" . " =" . " '$username'"; $usernamecheck = mysql_query($sqlusernamecheck, $cxn); $usernameif = (mysql_num_rows($usernamecheck)); $handle = fopen('file.txt', 'w+'); //open file.txt for writing fwrite($handle, 'usernameif=' . $usernameif); //write the variable value to the file fclose($handle); ?> Link to comment https://forums.phpfreaks.com/topic/103389-outputting-a-result-to-another-php-file/#findComment-529957 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.