napalm Posted November 27, 2008 Share Posted November 27, 2008 is there a way to create a file once a button is created? like have a button and when it is clicked it creates a html file into a directory? and possibly have a button when the button is clicked to create it have it so it changes to a remove button and it removes the html file? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted November 27, 2008 Share Posted November 27, 2008 It would require Ajax. Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted November 27, 2008 Share Posted November 27, 2008 Yes, look into fwrite, and unset Quote Link to comment Share on other sites More sharing options...
Maq Posted November 27, 2008 Share Posted November 27, 2008 create delete Quote Link to comment Share on other sites More sharing options...
napalm Posted November 27, 2008 Author Share Posted November 27, 2008 No im pretty sure you can do this in php yeah i know fwrite.. but thats only when u vist the page it creates it im wondering if theres a way for when u click a link it does it? i know about all them.. BUT ON A BUTTON CLICK... Quote Link to comment Share on other sites More sharing options...
Maq Posted November 27, 2008 Share Posted November 27, 2008 No im pretty sure you can do this in php yeah i know fwrite.. but thats only when u vist the page it creates it im wondering if theres a way for when u click a link it does it? Yes! Make a link to a .php page and use the information in the links I gave you. Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted November 27, 2008 Share Posted November 27, 2008 AJAX uses PHP. It can call a PHP page without reloading. Quote Link to comment Share on other sites More sharing options...
napalm Posted November 27, 2008 Author Share Posted November 27, 2008 No help for what im doing.. i need a button i guess i can try and code somthing.. and play around with stuff but me kinda lazy XD Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted November 27, 2008 Share Posted November 27, 2008 What are you talking about? Quote Link to comment Share on other sites More sharing options...
trq Posted November 27, 2008 Share Posted November 27, 2008 <form action="" method="post"> <input type="button" name="create" value="create_file"> </form> <?php if (isset($_POST['create'])) { // create the file } ?> Quote Link to comment Share on other sites More sharing options...
napalm Posted November 27, 2008 Author Share Posted November 27, 2008 Great! Umm and if i want it so it sets the name of the file? Quote Link to comment Share on other sites More sharing options...
trq Posted November 27, 2008 Share Posted November 27, 2008 Then you would need a text input field within your form to grab the name. Quote Link to comment Share on other sites More sharing options...
Maq Posted November 27, 2008 Share Posted November 27, 2008 This kid is not going to learn anything if you just give him the code. Quote Link to comment Share on other sites More sharing options...
napalm Posted November 27, 2008 Author Share Posted November 27, 2008 nono.... like: <form action="" method="post"> <input type="button" name="create" value="create_file"> </form> <?php if (isset($_POST['create'])) { $create = "File.html"; $create = fopen($create, 'w') or die("can't open file"); fclose($ourFileHandle); } ?> ???? Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted November 27, 2008 Share Posted November 27, 2008 We are not here to write it for you , you need to learn from the links you were given and then try and make it yourself. Once you have done that, if you get an error come back here and we will help. Quote Link to comment Share on other sites More sharing options...
trq Posted November 27, 2008 Share Posted November 27, 2008 This kid is not going to learn anything if you just give him the code. Pipe down, it was a simple example. nono.... like: <form action="" method="post"> <input type="button" name="create" value="create_file"> </form> <?php if (isset($_POST['create'])) { $create = "File.html"; $create = fopen($create, 'w') or die("can't open file"); fclose($ourFileHandle); } ?> ???? Is that meant to be a question? Quote Link to comment Share on other sites More sharing options...
Maq Posted November 27, 2008 Share Posted November 27, 2008 Pipe down, it was a simple example. Sorry, but when someone starts a thread on how to create a file and doesn't even know how to create a submission button, it makes me think he just wants a CnP solution... And in-case you couldn't figure out the delete part: if (isset($_POST['create'])) { $create = "File.html"; $create = fopen($create, 'w') or die("can't open file"); fclose($ourFileHandle); } if (isset($_POST['delete'])) { $delete = "File.html"; unlink($delete); } ?> </pre> <form action="<?php%20echo%20%24_SERVER%5B'PHP_SELF'%5D;%20?>" method="post"> < Quote Link to comment Share on other sites More sharing options...
napalm Posted November 27, 2008 Author Share Posted November 27, 2008 atm.. yes.. i want a cnp solution.. realllyyy sleepy and not thinkging straight but wants to finish what ever im working on idk atm hahaha.. sorry bout this thanks though! Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted November 27, 2008 Share Posted November 27, 2008 Topic Solved , bottom left. Also when tired, sleep then work on the it when you wake up again because its hard to concentrate otherwise. Quote Link to comment Share on other sites More sharing options...
Maq Posted November 27, 2008 Share Posted November 27, 2008 atm.. yes.. i want a cnp solution.. realllyyy sleepy and not thinkging straight but wants to finish what ever im working on idk atm hahaha.. sorry bout this thanks though! What? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.