|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (9 bit)
Join Date: Sep 2004
Posts: 418
|
A Couple (Hopefully) Simple PHP Questions
Hi, I just started with PHP and so far its going pretty well, but theres a couple of quesitons that I have about a program I'm working on to save and open files.
1.) I want two buttons after a text area, one that says save and one that says open. I'd like seperate PHP files to handle each of these functions (save.php and open.php or whatever). The problem is that I can't figure out how to do this within one HTML form, since you specify the php file when you declare the form and not in the submit buttons. What I have so far for the form is (with @ replacing <) @form method="post" action="savenotes.php"> @textarea name="notesection" rows="20" cols="65" wrap="hard"> @/TEXTAREA> Username: @input type="text" name="user" size="20"> @input type="submit" Value="Save Text"> @/form> As you can see, where it says action I don't know what to do. Also I haven't added the open button yet, but it will be the same 2.) I want my php file to do something (update a text file), but I don't want it to ever have to display anything in the web page. Is there an easy way that I can just let it do what it has to in saving the file and then redisplay the HTML page that called it? Thanks A lot, Graeme |
|
|
|
|
|
#2 |
|
Member (9 bit)
Join Date: Jan 2006
Posts: 343
|
1.) I had a similar problem for my search. I wanted to have an option for searching google or my database. Hint: your files must both use either GET or POST. I have to strip the HTML out of my code. I can email it to you if you wish.
a.) create your form:*form name='seeker' method='get' onSubmit='javascript:route();'> b.) create a select and set the option values to point to your files:*select size='1' name='engine'>*option value='myFirstFile.php'>MyFirstFile*/option>*option value='mySecondFile.php'>MySecondFile*/option> */select> c.) Insert a javascript like this to direct your input to the selected file: *script language='javascript' type='text/javascript'> function route(){ var action = document.seeker.engine.value; document.seeker.action=action; document.seeker.submit();} */script> NOTE: you could try something like this for two buttons, though I cannot guarantee this will work. a.) create a form like this: *form name='seeker' method='GET'> b.)create your buttons like this: *input type='button' value='save' onClick='javascript:save()'> *input type='button' value='open' onClick='javascript pen()'>c.) insert a javascript like so: *script language='javascript' type='text/javascript'> function save(){ document.seeker.action=save.php; document.seeker.submit();} function open(){ document.seeker.action=open.php; document.seeker.submit();} */script> 2.)I'm not really sure what you want to do here. You can use fread and fseek to set and write wherever you want to in a file. Last edited by DynamicTech; 01-05-2006 at 09:07 PM. |
|
|
|
|
|
#3 |
|
Member (7 bit)
Join Date: Dec 2005
Posts: 87
|
The easiest way to do this is to just give the buttons two different values, for instance and
When you send the information, the values of submit will be sent too. So you can do if($_GET['submit']=="Save") or if($_GET['submit']=="Open") The trick is to think of a button just like a text field. It passes information through get or post like all others. |
|
|
|
|
|
#4 |
|
Member (7 bit)
Join Date: Dec 2005
Posts: 87
|
Haha, these forums don't escape Html entities. That's pretty funny. Someone can really screw stuff up here if they know what they're doing.
The code is: input type="submit" name="submit" value="Open" and input type="submit" name="submit" value="Save" just put the two into brackets "<>" |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|