Page 1 of 1

form button not working

Posted: Mon Sep 08, 2003 9:51 pm
by m3rajk
the button to call the block.php page doesn't worrk. i've used submits and resets before, but not buttons. so i'm not sure what's wrong here. if anyone can explain it, i would really like to know.

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>FindYourDesire.com -- Reading/Sending FYDim</title>
    <meta name="Author" content="Pages coded by Josh Perlmutter for Desired Creations LLC">
    <meta name="Author" content="Graphics created by Alix Stolzer for Desired Creations LLC">
    <meta name="Author" content="Smileys created by Amber Beausoleil for Desired Creations LLC">
    <style type="text/css">
      <!-- this comment is for non-css compliant browsers
      a &#123;text-decoration:none&#125;
      end of css -->
    </style>
  </head>

  <body bgcolor="#878787" text="#ffffff" alink="#950c0c" vlink="#3347c5" link="#000000">
    <center>    <form action="/findyourdesire/message.php" method="POST" onReset="window.close();" style="margin:0">
      <input type="hidden" name="to" value="Jersey_Girl17">
      <table frame="box" bgcolor="#878787" border="1" cellpadding="0" cellspacing="0" text="#ffffff">
	  <tr>
	    <td rowspan="3" width="75" height="75"><a href="profile.php?un=Jersey_Girl17" target="profile"><img border="0" src="pic.php?pic=main.Jersey_Girl17.jpg&fn=ltn"></a></td>
	    <td colspan="2">Message To/From: <a href="profile.php?un=Jersey_Girl17" target="profile">Jersey_Girl17</a></td>

	    <td colspan="2"><input type="button" name="block" value="Block User" onClick="window.self('block.php');"></td>
	  </tr>
	  <tr>
	    <td colspan="3"></td>
	    <td ><a href="code.php" target="code">SiteCode</a> On</td>
	  </tr>
	  <tr>

	    <td><input type="submit" value="Send Mail"></td>
	    <td><input type="reset" value="Close Window"></td>
	    <td colspan="2"><a name="#desire" href="#desire" onClick="window.open('adddesire.php?fun=Jersey_Girl17&fuin=13', 'desire', 'height=196,width=288');">Add Desire</a></td>
	  </tr>

	  <tr>
	    <td colspan="5"><textarea name="message" rows="5" cols="59"></textarea></td>
	  </tr>
      </table>

    </form>
      <font size="-2">
      <p>Pages coded by Josh Perlmutter for Desired Creations LLC
	<br />Graphics created by Alix Stolzer for Desired Creations LLC
	<br />Smileys created by Amber Beausoleil for Desired Creations LLC
	<br />All creations copyrighted by their respective Creators. Reproduction Requires Consent of the Creator and Desired Creations LLC.
      </p>
    </font>
    </center>
  </body>
</html>

Posted: Mon Sep 08, 2003 10:07 pm
by nigma
window.open()?

Posted: Tue Sep 09, 2003 9:20 am
by Vincent Puglia
howzabout: onclick="window.location='block.php'"

Vinny

Posted: Tue Sep 09, 2003 9:36 am
by JayBird
those methods won't pass any info from the current page though!!

You need to change the action of the form and subit it using Javascript.

Try this code

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
  <head> 
    <title>FindYourDesire.com -- Reading/Sending FYDim</title> 
    <meta name="Author" content="Pages coded by Josh Perlmutter for Desired Creations LLC"> 
    <meta name="Author" content="Graphics created by Alix Stolzer for Desired Creations LLC"> 
    <meta name="Author" content="Smileys created by Amber Beausoleil for Desired Creations LLC"> 
    <style type="text/css"> 
      <!-- this comment is for non-css compliant browsers 
      a &#123;text-decoration:none&#125; 
      end of css --> 
    </style> 
<script language="JavaScript" type="text/JavaScript">

function blockUser() &#123;
	document.findyourdesire.action="block.php";
	document.findyourdesire.submit();
&#125;

</script>
  </head> 

  <body bgcolor="#878787" text="#ffffff" alink="#950c0c" vlink="#3347c5" link="#000000"> 
    <center>    <form name="findyourdesire" action="/findyourdesire/message.php" method="POST" onReset="window.close();" style="margin:0"> 
      <input type="hidden" name="to" value="Jersey_Girl17"> 
      <table frame="box" bgcolor="#878787" border="1" cellpadding="0" cellspacing="0" text="#ffffff"> 
     <tr> 
       <td rowspan="3" width="75" height="75"><a href="profile.php?un=Jersey_Girl17" target="profile"><img border="0" src="pic.php?pic=main.Jersey_Girl17.jpg&fn=ltn"></a></td> 
       <td colspan="2">Message To/From: <a href="profile.php?un=Jersey_Girl17" target="profile">Jersey_Girl17</a></td> 

       <td colspan="2"><input type="button" name="block" value="Block User" onClick="blockUser();"></td> 
     </tr> 
     <tr> 
       <td colspan="3"></td> 
       <td ><a href="code.php" target="code">SiteCode</a> On</td> 
     </tr> 
     <tr> 

       <td><input type="submit" value="Send Mail"></td> 
       <td><input type="reset" value="Close Window"></td> 
       <td colspan="2"><a name="#desire" href="#desire" onClick="window.open('adddesire.php?fun=Jersey_Girl17&fuin=13', 'desire', 'height=196,width=288');">Add Desire</a></td> 
     </tr> 

     <tr> 
       <td colspan="5"><textarea name="message" rows="5" cols="59"></textarea></td> 
     </tr> 
      </table> 

    </form> 
      <font size="-2"> 
      <p>Pages coded by Josh Perlmutter for Desired Creations LLC 
   <br />Graphics created by Alix Stolzer for Desired Creations LLC 
   <br />Smileys created by Amber Beausoleil for Desired Creations LLC 
   <br />All creations copyrighted by their respective Creators. Reproduction Requires Consent of the Creator and Desired Creations LLC. 
      </p> 
    </font> 
    </center> 
  </body> 
</html>
Mark

Posted: Tue Sep 09, 2003 9:41 am
by Vincent Puglia
hi bech

As I posted, no; but, you could append whatever is needed to the location string and then handle it server side:

window.location = "block.php?blahblah"

Vinny

Posted: Tue Sep 09, 2003 9:42 am
by JayBird
true, but the form is using POST, my way will do it using POST too ;)

Posted: Tue Sep 09, 2003 9:46 am
by Vincent Puglia
Hi bech,

I defer to the phper :D

Vinny

Posted: Tue Sep 09, 2003 9:48 am
by JayBird
LOL :lol:

Posted: Tue Sep 09, 2003 9:56 am
by m3rajk
there's no reason i reallly need to use pos aside form the fact it would stop people from creating links to get people to block other users by clicking on them.. but since i alredy have the way to remove them is that really an issue? not sure which is the simpler solution right now

Posted: Tue Sep 09, 2003 10:00 am
by JayBird
i don't think either metod is simpler or not really, just two methods of doing the same thing, but as you said, the POST method may be safer, even though that can still be faked!

Mark

Posted: Tue Sep 09, 2003 2:02 pm
by JAM
Did I miss something? Why not use more than one submit button?

Code: Select all

<pre>
<?php
    // just examples...
    print_r($_POST);
    if (isset($_POST['block'])) {
        echo 'Run functions for blocking, header to another page...';
    } else if (isset($_POST['send'])) {
        echo 'Run functions for sending mail';
    }
?>
<form method="post">
<input type="text" name="something" value="example">
<input type="submit" name="block" value="Block User">
<input type="submit" name="send" value="Send Mail">
</form>

Posted: Tue Sep 09, 2003 4:05 pm
by JayBird
Yeah jam, that could be another way of doing it, but his block user script is currently in another .php file, so the way we suggested saves re-writing code.

Mark

Posted: Tue Sep 09, 2003 10:40 pm
by JAM
Hmmm... Having the rewriting in mind, youre right.

I did something similiar, where I instead included my 'block' file, as opposite to header()/window.open it.