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 Link to comment https://forums.phpfreaks.com/topic/16127-if-question/ 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] Link to comment https://forums.phpfreaks.com/topic/16127-if-question/#findComment-66512 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 Link to comment https://forums.phpfreaks.com/topic/16127-if-question/#findComment-66513 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 Link to comment https://forums.phpfreaks.com/topic/16127-if-question/#findComment-66514 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 Link to comment https://forums.phpfreaks.com/topic/16127-if-question/#findComment-66530 Share on other sites More sharing options...
Ferenc Posted July 31, 2006 Share Posted July 31, 2006 $_POST['$submit_information']remove the $ Link to comment https://forums.phpfreaks.com/topic/16127-if-question/#findComment-66532 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 :) Link to comment https://forums.phpfreaks.com/topic/16127-if-question/#findComment-66533 Share on other sites More sharing options...
smti Posted July 31, 2006 Author Share Posted July 31, 2006 Thanks for the quick replies. Link to comment https://forums.phpfreaks.com/topic/16127-if-question/#findComment-66581 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 Link to comment https://forums.phpfreaks.com/topic/16127-if-question/#findComment-66890 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.