| Author |
Message |
West
Butt Sniffer


Joined: 27 Mar 2003 Posts: 1821
Location: Stealthed
|
Posted:
Mon Aug 04, 2003 10:20 am Post subject: A few questions about PHP |
|
How can I store a variable from an HTML from into a text document and how can i read the variable back into php from the text document?
Is there any structure to the variables? Do I have to declare them?
Can I alter the variables from one type to the other? (ie is there something like text1.text:=IntToStr(Number1*Number2); )
My host doesn't support MySQL and I was going to write a php shout box (I think I should be able to do that). I have a feeling that you could post PHP into the shoutbox so that it stores the php in the text document. When it comes to retrieve the text and the php it would parse it as part of my site? For example could someone post an infinate while loop and hang the browser? Could that happen and could I stop it?
Any books you would recommend also?
I set up an Apache server just so I could practise PHP and I love it |
_________________
|
|
|
|
|
Lycander
Lead Dog


Joined: 24 May 2002 Age: 25 Posts: 12198
Location: The Constitution State
|
Posted:
Mon Aug 04, 2003 10:38 am Post subject: |
|
If you have MS Access, I think PHP can read/write to an MDB file which will make it easier on you. You have to consider the worst case scenario which is 2 people trying to post at the same time and you get a file I/O collision.
I believe to get variables from a POST form, you access the variable's data via:
$_POST['name']
where name is the name of the HTML form object like a text box.
Go to www.php.net and find your way to the documentation download section. You can download the PHP docs in many formats (PDF, HTML tarball, CHM) and look up the routines you want to use. Like if you need to convert a binary number into its string representation there's a rountine for that.
And if someone wants to get cleaver and put PHP code in their post, you could do some validation on the post to make sure they're posting just text and not PHP or Javascript. As far as PHP code goes, I don't think you'll have to worry because it'll just output it as text to the user and they'll see the code in their web browser, but the PHP parser on the server side just prints out the text and moves on with execution in this particular script. The only way to throw it off track from execution in the current script is either by #include directives or calling an external routine (also included via #include). |
|
|
|
|
|
|
West
Butt Sniffer


Joined: 27 Mar 2003 Posts: 1821
Location: Stealthed
|
Posted:
Mon Aug 04, 2003 11:04 am Post subject: |
|
Thanks Ly. |
_________________
|
|
|
|
|
Lycander
Lead Dog


Joined: 24 May 2002 Age: 25 Posts: 12198
Location: The Constitution State
|
Posted:
Mon Aug 04, 2003 11:36 am Post subject: |
|
You're welcome.
Nice panties. |
|
|
|
|
|
|
BamZipPow
Alpha Dog


Joined: 02 Aug 2001 Posts: 18021
Location: Driving EEp all over the place...
|
Posted:
Mon Aug 04, 2003 12:03 pm Post subject: |
|
Lycander wrote:Nice panties.
|
_________________ BamZipPow
...all yer EEps belong to Bam!
     
|
|
|
|
|
West
Butt Sniffer


Joined: 27 Mar 2003 Posts: 1821
Location: Stealthed
|
Posted:
Mon Aug 04, 2003 12:17 pm Post subject: |
|
Haha got it sorted
http://tinyurl.com/izhp to take my test. (Please dont be offended, its just a joke. Its safe btw)
I'll post my code in a minute if anyone is interested. |
_________________
Last edited by West on Mon Aug 04, 2003 12:24 pm; edited 2 times in total
|
|
|
|
|
Lycander
Lead Dog


Joined: 24 May 2002 Age: 25 Posts: 12198
Location: The Constitution State
|
Posted:
Mon Aug 04, 2003 12:18 pm Post subject: |
|
BamZipPow wrote:Lycander wrote:Nice panties.

Look at the girl in the white skirt dancing in his sig. |
|
|
|
|
|
|
seca111
Leg Humper


Joined: 12 May 2003 Posts: 4778
Location: Franktown, Colorado
|
Posted:
Mon Aug 04, 2003 12:43 pm Post subject: |
|
CONGRATULATIONS, YOU'RE MEDIOCRE!
Only mediocre.... I thought I was at least above average with my responses. |
|
|
|
|
|
|
Lycander
Lead Dog


Joined: 24 May 2002 Age: 25 Posts: 12198
Location: The Constitution State
|
Posted:
Mon Aug 04, 2003 12:46 pm Post subject: |
|
For a minute there I thought I was the only one on the list of wankers. Whew. |
|
|
|
|
|
|
West
Butt Sniffer


Joined: 27 Mar 2003 Posts: 1821
Location: Stealthed
|
Posted:
Mon Aug 04, 2003 12:53 pm Post subject: |
|
There was about 70 on it, but I kept deleting it. I removed the Proceed button but it must have still been stored on peoples comps so I was still getting them :S |
_________________
|
|
|
|
|
West
Butt Sniffer


Joined: 27 Mar 2003 Posts: 1821
Location: Stealthed
|
Posted:
Mon Aug 04, 2003 1:01 pm Post subject: |
|
This is how I wrote and read from a text file if anyone is interested.
To read
$filename = "file.txt";
$list = file_get_contents($filename);
To write
$two = $_POST['sname'];
$one = $_POST['wank'];
$space = " wanks for ";
$after = " per week, ";
$combined = "";
$combined .= $two;
$combined .= $space;
$combined .= $one;
$combined .= $after;
$combined .= $list;
$fp = fopen("wank.txt", "w");
fputs ($fp, $combined);
fclose($fp); |
_________________
|
|
|
|
|
|
|