Jump to content

Outputting a result to another PHP file?


chosendesigns

Recommended Posts

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

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

 

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);
?>

Archived

This topic is now archived and is closed to further replies.

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