smti Posted July 31, 2006 Share Posted July 31, 2006 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> </td> <td><font size="1">Room Number:</font></td> <td><input type="text" id="room_location" name="room_location"/> </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"/> <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 Quote Link to comment Share on other sites More sharing options...
Ferenc Posted July 31, 2006 Share Posted July 31, 2006 [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] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted July 31, 2006 Share Posted July 31, 2006 The array is [b]$_POST[/b] not [b]$_post[/b]. There is a difference.Ken Quote Link to comment Share on other sites More sharing options...
Chetan Posted July 31, 2006 Share Posted July 31, 2006 [code] <? if (isset($_post['$submit_data'])) { echo "Test completed!"; } ?>[/code]Simple as thatit 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 didI dont think PHP is case sensative and ya right Ferenc Quote Link to comment Share on other sites More sharing options...
smti Posted July 31, 2006 Author Share Posted July 31, 2006 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> </td> <td><font size="1">Room Number:</font></td> <td><input type="text" id="room_location" name="room_location"/> </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"/> <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 Quote Link to comment Share on other sites More sharing options...
Ferenc Posted July 31, 2006 Share Posted July 31, 2006 $_POST['$submit_information']remove the $ Quote Link to comment Share on other sites More sharing options...
ryanlwh Posted July 31, 2006 Share Posted July 31, 2006 it's $_POST['submit_information'], without the $ before submit. also check your php.ini and make sure register_globals is OFFEDIT: Ferenc beat me :) Quote Link to comment Share on other sites More sharing options...
smti Posted July 31, 2006 Author Share Posted July 31, 2006 Thanks for the quick replies. Quote Link to comment Share on other sites More sharing options...
Chetan Posted August 1, 2006 Share Posted August 1, 2006 I told you to remove the $ sign earlier, dint i Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.