Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 01-04-2006, 10:16 PM   #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
GraemeM is offline   Reply With Quote
Old 01-05-2006, 10:03 AM   #2
Member (9 bit)
 
DynamicTech's Avatar
 
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='javascriptpen()'>
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.
DynamicTech is offline   Reply With Quote
Old 01-09-2006, 01:48 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.
hartken is offline   Reply With Quote
Old 01-09-2006, 01:50 PM   #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 "<>"
hartken is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:02 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2