Jump to content

IF Question


smti

Recommended Posts

Hello,

I have a bit of an issue with an IF statement. I have a form setup and I am attempting to process the data within the same file. Below is a copy of my code:

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

                   
                    <fieldset>
<legend>Basic Information</legend>
                    <table>
<tr>
                         
<td><font size="1">Building Location:</font></td>

<td><select name="building_location">
<option value=blank selected=selected>
<option value=bo>Business Office
<option value=us>Upper School
<option value=ms>Middle School
                    <option value=ls>Lower School
                    </select> &nbsp; &nbsp;</td>
                   
                   
                    <td><font size="1">Room Number:</font></td>
                    <td><input type="text" id="room_location" name="room_location"/> &nbsp;&nbsp;</td>



                        <td><font size="1">Serial Number:</font></td>
                        <td><input type="text" id="item_serial" name="item_serial"/></td>
</table>
                    </fieldset>
                   
                   
<br>
                       
<fieldset>
<legend>Item Information</legend>
           
<p><label for="make"><font size="1">Computer Make:</font></label>
                        <input type="text" id="make" name="computer_make"/>

                        <p><label for="model"><font size="1">Computer Model:</font></label>
                        <input type="text" id="model" name="computer_model"/>

                        <p><label for="cpu"><font size="1">Processor Specs:</font></label>
                        <input type="text" id="cpu" name="cpu"/>
                       
<p><label for="Storage Capacity"><font size="1">Storage Capacity:</font></label>
<input type="text" id="storagecap" name="hd"/>

<p><label for="OS"><font size="1">Operating System:</font></label>
<input type="text" id="OS" name="os"/>

<p><label for="mac"><font size="1">MAC Address:</font></label>
<input type="text" id="mac" name="mac"/>
</fieldset>

                        <br><br>
                       
                        <fieldset>
                        <legend>Notes</legend>
                       
                        <textarea rows="15" cols="30" name="notes"></textarea>
</fieldset>



<br><br>


                        <input type="submit" name="submit_data" value="Add Asset"/> &nbsp; &nbsp; <input type="reset"     name="reset_data"/>
                        <input type="hidden" name="submitted" value=true/>

                  </form>
             
             
<?
             
              if (isset($_post['$submit_data']))
                { 
  echo "Test completed!";
}

?>
I can not get the IF to work. I am not quite sure what the problem is. Any help would be greatly appreciated! I apologize for the long code.


Thanks in advance,
Jared
Link to comment
Share on other sites

[code]

<?
if (isset($_POST['submit_data']))
{

  // process data

  echo "Test completed!";

  //  end the script
  exit;
}
// display form if submit_data was not set
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">...........[/code]
Link to comment
Share on other sites

[code]
<?
             
              if (isset($_post['$submit_data']))
                { 
              echo "Test completed!";
            }
           
            ?>
[/code]

Simple as that
it should be $_POST['submit_data'] not $_post['$sudmit_data']

[code]
<?
             
              if (isset($_POST['submit_data']))
                { 
              echo "Test completed!";
            }
           
            ?>
[/code]
bumped i was posting while u did
I dont think PHP is case sensative and ya right Ferenc
Link to comment
Share on other sites

Hello,

I made the changes:


<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">

                   
                    <fieldset>
<legend>Basic Information</legend>
                    <table>
<tr>
                         
<td><font size="1">Building Location:</font></td>

<td><select name="building_location">
<option value=blank selected=selected>
<option value=bo>Business Office
<option value=us>Upper School
<option value=ms>Middle School
                    <option value=ls>Lower School
                    </select> &nbsp; &nbsp;</td>
                   
                   
                    <td><font size="1">Room Number:</font></td>
                    <td><input type="text" id="room_location" name="room_location"/> &nbsp;&nbsp;</td>



                        <td><font size="1">Serial Number:</font></td>
                        <td><input type="text" id="item_serial" name="item_serial"/></td>
</table>
                    </fieldset>
                   
                   
<br>
                       
<fieldset>
<legend>Item Information</legend>
           
<p><label for="make"><font size="1">Computer Make:</font></label>
                        <input type="text" id="make" name="computer_make"/>

                        <p><label for="model"><font size="1">Computer Model:</font></label>
                        <input type="text" id="model" name="computer_model"/>

                        <p><label for="cpu"><font size="1">Processor Specs:</font></label>
                        <input type="text" id="cpu" name="cpu"/>
                       
<p><label for="Storage Capacity"><font size="1">Storage Capacity:</font></label>
<input type="text" id="storagecap" name="hd"/>

<p><label for="OS"><font size="1">Operating System:</font></label>
<input type="text" id="OS" name="os"/>

<p><label for="mac"><font size="1">MAC Address:</font></label>
<input type="text" id="mac" name="mac"/>
</fieldset>

                        <br><br>
                       
                        <fieldset>
                        <legend>Notes</legend>
                       
                        <textarea rows="15" cols="30" name="notes"></textarea>
</fieldset>

<br><br>


                        <input type="submit" name="submit" value="Add Asset"/> &nbsp; &nbsp; <input type="reset"     name="reset_data"/>
                        <input type="hidden" name="submit_information" value=true/>

                        </form>
              <?
             
             
              if (isset($_POST['$submit_information']))
                { 
  echo "Test completed!";
}

?>





I am still not having any luck.

Thanks,

Jared
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.