View Full Version : fopen, fclose, fwrite....
pcbrainbuster
03-07-2007, 04:51 PM
Hello :),
I am a total begginer to PHP and need to know about the functions in the title - fopen, fclose, fwrite (and if there are more then them to) and why does it have f in front of it :)
And just one more thing :)
How do set PHP to start itself only when something has been clicked for a example a button ?
pcbrainbuster
03-07-2007, 05:37 PM
Please tell me :(
How do set PHP to start itself only when something has been clicked for a example a button ?Don't send the request until the button is clicked.
I am a total begginer to PHP and need to know about the functions in the title - fopen, fclose, fwrite (and if there are more then them to) and why does it have f in front of itBecause it deals with files. They mimic the C functions.
Other than what's in the PHP docs (which I'm going to optimistically assume you've read), there's not really much more to them. You open a file with fopen(), read/write from it with fread()/fwrite(), then close it with fclose().
Please tell me :(Patience is a virtue.
pcbrainbuster
03-07-2007, 06:49 PM
I understand completely the f functions but stll i do not get the don't send the request untl the button is clicked part.
<form action="dosomething.php">
<input type="submit" value="Do Something">
</form>
pcbrainbuster
03-07-2007, 07:01 PM
Thanks :),
I understand that now but one thing still haunts me... How would you simply stop PHP i mean in javascript you would do somthing like this -
<button id="id" onclick="asd()">Corck</button>
<script type="thetype">
function asd() {
the scripts
}
</script>
so the function part stops the scriipt from running if the button has not been clicked. but if you do that form thing the php script still has not function thing over it to stop it and how do you even asihn php a function name like asd().
Please give an example with php having an function name asined to it plus a button which is clicked for the php art to activate.
pcbrainbuster
03-07-2007, 08:40 PM
Please can you give me an example of the above :)?
mburt
03-07-2007, 08:53 PM
You have to understand that PHP does not interact with the DOM, or dynamically change things on the page.
As Twey posted, you would have to send the request to a page to change the data using <form>.
pcbrainbuster
03-07-2007, 08:58 PM
Well may i please have an example ? :),
Plus can javascript read/write/open/close files and can it also run php within it self like this -
<button onclick="asd()">Test</button>
<script>
function asd() {
<?php
echo "You fool !"
?>
}
</script>
Well can it ? :confused:
Demonicman
03-07-2007, 09:18 PM
test it in wamp... im pretty sure it will work but not 100%
pcbrainbuster
03-07-2007, 09:59 PM
Here is what i want to be able to do in PHP if its even possible :) -
Read the value written in a prompt box and then echo it onto the page...
(and please answer the question aboove)
boxxertrumps
03-07-2007, 11:05 PM
Plus can javascript read/write/open/close files
No. Thats what PHP is for.
PHP stands for Pre-client Hypertext Processor. As in, your web browser never sees the PHP code.
if you looked in your source, all you would see is this...
<button onclick="asd()">Test</button>
<script>
function asd() {
You fool !
}
</script>
You would need ajax to send the data to a php script, then put the result somewhere on your page.
pcbrainbuster
03-08-2007, 07:55 AM
Yeah... I forgot about the parsing part of PHP. But I still don't understand the whole running PHP when its needed part - for an example say I wanted to click a button and make the time from PHP show up - how would that be done ?
(I know that PHP does not connect with DOM but there should be a way to respond to things the user does - what can you really do with PHP apart from opening files closing them writing to them reading them ?)
pcbrainbuster
03-08-2007, 04:31 PM
Well is there anything else ???
pcbrainbuster
03-08-2007, 04:46 PM
Ok i was on the web and found this password script -
<form method="POST" action="example18.php3">
<div align="left"><p><font face="BankGothic Md BT">Admin password?</font>
<input type="password" name="pw" size="14"><input type="submit" value="Submit"></p>
</div></form>
How is this php script connecting to that -
<?
$adminpass = "test123";
if ($pw == $adminpass)
{
print("Welcome to the administration area!");
}
else
{
print("Wrong password");
}
?>
I wonder :)
Demonicman
03-09-2007, 04:31 AM
im sure if you set a cookie you would be safer, that way you can check the cookie for the correct username and password
pcbrainbuster
03-09-2007, 04:21 PM
You misunderstand :), what i needed to know is how this works but now understand most of it and now instead need to know that if only one submit button is allowed in a form (then it would make sense to me on how the whole thing works)
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.