Jump to content


Photo

IF Question


  • Please log in to reply
8 replies to this topic

#1 smti

smti
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 31 July 2006 - 06:08 PM

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


#2 Ferenc

Ferenc
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts

Posted 31 July 2006 - 06:17 PM


<?
 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">...........

Everything you want to know is here.

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 31 July 2006 - 06:17 PM

The array is $_POST not $_post. There is a difference.

Ken

#4 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 31 July 2006 - 06:19 PM

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

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

 <?
              
              if (isset($_POST['submit_data']))
                {  
              echo "Test completed!";
            }
            
            ?>
bumped i was posting while u did
I dont think PHP is case sensative and ya right Ferenc
I am a PHP Guru, ask me questions if you want to

#5 smti

smti
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 31 July 2006 - 06:39 PM

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

#6 Ferenc

Ferenc
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts

Posted 31 July 2006 - 06:41 PM

$_POST['$submit_information']

remove the $
Everything you want to know is here.

#7 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 31 July 2006 - 06:42 PM

it's $_POST['submit_information'], without the $ before submit.

also check your php.ini and make sure register_globals is OFF

EDIT: Ferenc beat me :)
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#8 smti

smti
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 31 July 2006 - 07:41 PM

Thanks for the quick replies.

#9 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 01 August 2006 - 09:05 AM

I told you to remove the $ sign earlier, dint i
I am a PHP Guru, ask me questions if you want to




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users