Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Button to call php page from html

Status
Not open for further replies.

rouse01

IS-IT--Management
Sep 10, 2001
143
US
I'm fairly new to html & php, so I don't know if this is possible...
Trying to add another button to an html form to call a php which is not the &quot;<form action&quot; of the page. Besides the default Submit & Reset buttons (which work fine), I need a Help button. I'm testing the 'Help' button by trying to call a page that has the:
<?php
echo phpinfo();
?>
In my html page, I've added...
<BUTTON name=&quot;help&quot; type=&quot;button&quot;> Help <img src=&quot;images/button.gif&quot; a href=&quot;info.php&quot; alt=&quot;Explanation&quot; border=0></a></BUTTON>

The submit fires another .php just fine. The reset clears the form. Also the info.php fires fine when I point my browser to it, but cannot figure how to get the button launch. Thanks in advance - Keith
 
It's probably possible to do it with 1 form but I don't know how.

If you don't need any of the fields in the form to be sent to the help php file, just add another form with the help button inside it as type submit. I've just tried this:

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;hello.php&quot;>
<input type=&quot;submit&quot; name=&quot;Hello&quot; value=&quot;Submit&quot;>
</form>
<form name=&quot;form2&quot; method=&quot;post&quot; action=&quot;help.php&quot;>
<input type=&quot;submit&quot; name=&quot;Help&quot; value=&quot;Submit&quot;>
</form>

and it works fine. If you need the first form's fields in the help php, let me know and I'll post some javascript to copy the values into the second form.
 
You can definately do it with javascript...

<input type=&quot;button&quot; src=&quot;images/button1.gif&quot; onclick=&quot;window.location='
I might be slightly off on the syntax, but that's the gist.

-Rob
 
Your question made me think of doing a context help which I've posted in the Javascript forum.

thread216-482639 It's not what you know, it's who knows it that counts.
 
Thanks guys & sorry so long on reply. I tried all three suggestions & am going with skiflyer. Tho I have to dump my nifty button.gif on the 'submit' & 'reset' because I can't figure how to replicate that in ski's 'input type...', but the new button does fire my infophp() now!
Is the &quot;onclick = &quot;window.location='...&quot; javascript & should I be worried about introducing javascript?

Thanks a mil,
Keith
 
I am not really sure what you want to do.

Do you want to just put a link to another page or do you want to submit the details in a form to another location?

a standard help button would be :
<a href=&quot;info.php&quot;><img src=&quot;images/button.gif&quot; alt=&quot;Explanation&quot; border=0></a>
There is no need to put it in a button.

otherwise if you want the info, just add different submit buttons to the form.

<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;submit&quot;>
<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;help&quot;>

On the page you submit to just include a test statement to find out what you want to do

if($_POST['submit']=&quot;submit&quot;)
{
//do normal stuff
}
if($_POST['submit']=&quot;help&quot;)
{
//do help stuff
}

no javascript - no problem
 
Thanks LittleHavoc,
I'm just trying to link. Since I have the submit & reset buttons already I wanted to add a third in the same style (with my imbedded image). I like your idea about having the form action=&quot;results.php&quot; look at the value=. Like I said, newbie here. This is a simple calculator form, and I'd like to give the user some general info about the purpose of the form.
If you care to reply, I would like the 'HELP' link to open in a window of it's own. Also, I've been referencing my input variables on the called results.php page with a syntax of $HTTP_POST_VARS[&quot;Con_Fname&quot;]. Would a
$_POST['Con_Fname'] be the same? My php.ini has register_globals = Off
Thanks in advance - Keith


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top