www.webdeveloper.com
Results 1 to 2 of 2

Thread: problem submitting the form to itself

  1. #1
    Join Date
    Dec 2004
    Posts
    8

    problem submitting the form to itself

    Hello,

    I am having a task where one form gets the data,submits the data to the database Oracle and then calls another form. In another form I am using javascript to handle few checks and for that I am submitting the form to itself.. but it doesnt work..

    Please help.
    Thank you in advance


    below are sections of my code:
    /*******************************************************************/
    First Script:form1.php

    PHP Code:
    echo "<form name='form_1' action='info_1.php' method='get'>";
    echo 
    "<table width='100%' border='0' cellspacing='3' cellpadding='1'>";
    echo 
    "<tr>";
    echo 
    "<td width='15%'><font size='2'>Animal Number <font color='#FF0000'>*</font></font></td>";
    echo 
    "<td width='39%'><input type='text' name='animal_ID' size='7' maxlength='7' value='$pfidr_id' onBlur='Check_pfidr();'></td>";
    echo 
    "<td width='18%'><font size='2'>Vendor <font color='#FF0000'>*</font></font></td>";
    echo 
    "<td width='28%'>";
    echo 
    "<select name='select_vendor'>";
           echo 
    "<option value='0'>-- Select Vendor --</option>";
           echo 
    "<option value='three springs scientific'>Three Springs Scientific</option>";
           echo 
    "<option value='nih'>NIH</option>";
           echo 
    "<option value='caribean national primate center'>Caribean National Primate Center</option>";
         echo 
    "</select>";
         echo 
    "</td>";
         echo 
    "</tr>";
     echo 
    "</table>";
     echo 
    "<p align='left'> <font color='#FF0000'><b><font size='2'>* Indicates Compulsory fields.</font></b></font></p>";
    echo 
    "<p align='left'>";
    ?>
    <input type="submit" name="Submit" value="Continue"></p> 
    Second Script: info_1.php
    /*******************************************************************/

    $value_id = $_GET['value_id'];
    $value_name = $_GET['value_name'];

    $result = save_bio_info($value_id, $value_name);
    if($result->EOF)
    {
    echo"<b> Data Not Saved Properly, Click back button of the browser to go back </b>";
    }
    else
    {
    include("form_2.php");
    }

    Third Script : form_2.php
    /*********************************************************************/

    <?php
    echo"<html>";
    echo"<head>";
    $weight = $_GET['animal_weight'];
    $height = $_GET['animal_height'];
    $cage = $_GET['select_cage'];
    $cagemate = $_GET['select_cagemate'];
    $building = $_GET['select_building'];
    $room = $_GET['select_room'];
    $studies = array();
    ?>
    <script language='JavaScript'>
    function Check_Weight()
    {
    var weight = document.forms[0].animal_weight.value;
    switch(weight)
    {
    case '0': alert('INVALID Number .. Please enter correct Animal weight !');
    break;
    case '' : alert('Animal Weight CANNOT be EMPTY');
    break;
    }
    if(weight > 100)
    {
    alert('INVALID Number .. Please enter correct Animal weight !');
    }
    }
    function Check_Height()
    {
    var height = document.forms[0].animal_height.value;
    switch(height)
    {
    case '0' : alert('INVALID Number .. Please enter correct Animal weight !');
    break;
    case '' : alert('Animal Weight CANNOT be EMPTY');
    break;
    }
    }
    </script>
    <?php
    echo "</head>";
    echo "<body>";
    echo "<center>";
    echo "<form name='bio_form_2' action='$PHP_SELF' method='get'>";
    echo "<p align='center'><font face='Arial, Helvetica, sans-serif' size='2'><b>Enter the Housing Information</b></font></p>";
    echo "<table width='100%' border='0' cellspacing='3' cellpadding='1'>";
    echo "<tr>";
    echo "<td width='19%'><font size='2'>Animal Number</font></td>";
    echo "<td width='81%'><input type='text' name='animal_ID' size='7' maxlength='7' value='$pfidr_id'></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td width='19%'><font size='2'>Animal Weight</font></td>";
    echo "<td width='81%'><input type='text' name='animal_weight' size='7' maxlength='7' onChange='Check_Weight();' value='$weight'><font size='2'>kgs. ( 0 - 100 )</font> </td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td width='19%'><font size='2'>Animal Height</font></td>";
    echo "<td width='81%'><input type='text' name='animal_height' size='7' maxlength='7' onChange='submit(this.selection);' value='$height'><font size='2'>kgs.( 0 - 100 )</font></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td width='19%'><font size='2'>Choose Cage</font></td>";
    echo "<td width='81%'>";
    echo "<select name='select_cage'>";
    echo "<option>-- Select Cage --</option>";
    // Query to get the cage types depending on the weight and height of the animal
    /*$query2 = "SELECT cage_id,cage_type FROM LOOKUP.Cage WHERE max_animal_weight >= '$weight' AND max_animal_height >= '$height'";
    $result2 = $db->Execute($query2) or die();
    $count2 = $result2->RecordCount();
    echo "Count2 = $count2";
    while($count2 != 0)
    {
    $cage_id = $result2->fields[0];
    $cage_name = $result2->fields[1];
    ?>
    <option value="<?php echo $cage_id; ?>"><?php echo $cage_name; ?></option>
    <?php
    $result2->MoveNext();
    $count2 = $count2 - 1;
    }*/
    echo "<option value='Other'>Other</option>";
    echo "</select>";
    echo "</td>";
    echo "</tr>";
    echo "</table>";
    echo "<p align='left'><a href='bio_form_3.php'><font face='Arial, Helvetica, sans-serif' size='2'>Continue</font></a></p>";

  2. #2
    Join Date
    Dec 2002
    Location
    Seattle, WA
    Posts
    1,843
    using multiple echoes for html is retarded, try this
    PHP Code:
    <?php
    echo <<<str
    <select name="select_vendor">
      <option value="0">-- Select Vendor --</option>
      <option value="three springs scientific">Three Springs Scientific</option>
      <option value="nih">NIH</option>
      <option value="caribean national primate center">Caribean National Primate Center</option>
    </select>
    str;
    ?>
    or
    PHP Code:
    <?php
    // ...
    ?>
    <select name="select_vendor">
      <option value="0">-- Select Vendor --</option>
      <option value="three springs scientific">Three Springs Scientific</option>
      <option value="nih">NIH</option>
      <option value="caribean national primate center">Caribean National Primate Center</option>
    </select>
    <?php
    // ...
    ?>
    or even
    PHP Code:
    <?php
    echo "<select name=\"select_vendor\">
      <option value=\"0\">-- Select Vendor --</option>
      <option value=\"three springs scientific\">Three Springs Scientific</option>
      <option value=\"nih\">NIH</option>
      <option value=\"caribean national primate center\">Caribean National Primate Center</option>
    </select>
    "
    ;
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles