Page 1 of 1

launching php file from button not link

Posted: Sun Feb 01, 2004 5:31 pm
by aerris
Hi... any help much appreciated!
I have created a file called addvenue.php with the following if condition at the start of it:

Code: Select all

<?php 
 if (isset($_GET['addvenue'])): // If the user wants to add a venue
?> 
<form action="<?=$_SERVER['PHP_SELF']?>" method="post"> 
<p>Venue Name<br /> 
<input type="text" name="vname" SIZE="40"><br /><BR>
<input type="submit" name="submitvenue" value="SUBMIT" /> 
</p> 
</form>  

<?php 
 else: // Default page display
in the default page display is a link that will reload the page making the if condition true, showing the submission form.

I can make the link work with a word:

Code: Select all

echo('<BR><a href="' . $_SERVER['PHP_SELF'] . 
      '?addvenue=1">Add a venue!</a><BR>');
But i really want it to be a button. I can make other button links such as:

Code: Select all

echo('<FORM METHOD="LINK" ACTION="addvenue.php">
<INPUT TYPE="submit" VALUE="Refresh Page"></FORM>');
That basically refreshes the page. Can i make a button link for the if condition too? I tried this:

Code: Select all

echo('<BR>
<FORM METHOD="LINK" ACTION="' . $_SERVER['PHP_SELF'] .'?addvenue=1"><INPUT TYPE="submit" VALUE="Add Venue">');
but it only reloads the same page...

anyone know why this is happening or how else i could do it? Am i going about this the wrong way?

thanks

Posted: Sun Feb 01, 2004 7:29 pm
by d3ad1ysp0rk
form method="get"

ok

Posted: Sun Feb 01, 2004 8:55 pm
by aerris
I tried:

Code: Select all

echo('<BR> 
<FORM METHOD="get" ACTION="' . $_SERVER['PHP_SELF'] .'?addvenue=1"><INPUT TYPE="submit" VALUE="Add Venue">');
but it still only reloads the page without running the if statement
:S

Posted: Sun Feb 01, 2004 9:04 pm
by d3ad1ysp0rk

Code: Select all

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<input type="hidden" name="addvenue" value="true">
<input type="submit" value="Submit">
</form>

Posted: Sun Feb 01, 2004 10:57 pm
by jaxn
You can do the hidden field (that works perfectly well), however you can also just use the post for method and put the condition in the form action:

Code: Select all

echo('&lt;BR&gt; 
&lt;FORM METHOD="post" ACTION="' . $_SERVER&#1111;'PHP_SELF'] .'?addvenue=1"&gt;&lt;INPUT TYPE="submit" VALUE="Add Venue"&gt;');
-Jackson

:D

Posted: Mon Feb 02, 2004 1:09 pm
by aerris
nice one cheers. :D