Jump to content

[SOLVED] form action 2 locations?


matt.sisto

Recommended Posts

Hello I am struggling getting this form to post to 2 separate locations depending on the submit button activated how can I do this?

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?php echo "date" ?></title>
<script language="JavaScript">
function win2() {
    window.open("checkavailability.php","Window2","menubar=no,width=460,height=360,toolbar=no");
}
</script>
</head>

<body>
<legend> Event Details
<form method="post" action="addevent.php">
<input type="text" name="event_title" size="25" maxlength="25" value="<?=$row['event_title']?>"/></p>
<p><strong>Event Description:</strong><br/>
<input type="text" name="event_shortdesc" size="25" maxlength="255" value="<?=$row['event_shortdesc']?>"/></p>

<p><strong>Event Date:</strong><br/>
<select name="year" value="<?=$row['y']?>">
<?php
       $yeartoday = date(Y);
       $yearplus1 = date(Y)+1;
         for($y=$yeartoday;$y<=$yearplus1;$y++){  
           $selected = "";
           $longDate = date("Y", mktime(0,0,0,1,1,$y));
           if ($Year==$y){ 
            $selected = "selected \n";
           }
           echo "<option value=\"$y\" $selected>$longDate</option> \n";
         }
?>
</select>

<select name="month" value="<?=$row['m']?>"/>
<?php
$months = Array("January", "February", "March", "April", "May",  "June", "July", "August", "September", "October", "November", "December");
for ($x=1; $x <= count($months); $x++) {
   echo"<option value=\"$x\"";
   if ($x == $month) {
      echo " selected";
   }
   echo ">".$months[$x-1]."</option>";
}
?>
</select>

<select name="day" value="<?=$row['d']?>">
<?php
for ($x= 1; $x<=31; $x++) {
   echo "<option";
   if ($x == $day) {
      echo " selected";
   }
   echo ">$x</option>";
}
?>
</select>

<p><input type ="submit" value="confirm"/>
<input type="button" onClick="javascript:self.close()" value="close">
<input type="submit" onClick="javascript:win2()" value="Check Availability"></p>
</legend>
</form>
</body>
</html>

 

 

Appreciate any help. 8)

Link to comment
https://forums.phpfreaks.com/topic/150370-solved-form-action-2-locations/
Share on other sites

You can't have them go to different locations, all you can do is check for each submit button wherever your form is pointing to.

 

if ($_POST['event_title']) {
  //handle title here
}
if ($_POST['event_shortdesc']) {
  //handle shortdesc here
}

I haven't explained what it is I want to do properly. When the client selects a date they can check the availability or add an event, depending on the submit button activated. But the date value must be used in the addevent.php or chekavailabilty.php.

 

http://www.salmonsreach.org/cal.php

 

if you activate a link to a date, then the addeventform.php opens in a popup window. Perhaps if you have a look at the form it would be easier to understand. :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.