jimmyelewis Posted March 23, 2006 Share Posted March 23, 2006 Hey,I have the following code[code]if (mysql_query ($query)) { echo 'The tool has been added.'; } else { echo '<p>Could not add the tool because <b>' . mysql_error() . '</b>. The query was ' .$query . '.</p>'; } mysql_close();}// Display form?><form action="index.php" method="post"><p>Tool Name: <input type="text" name="tool_name" size="40" maxsize="50" /></p><p>Tool Icon Name: <input type="text" name="tool_icon" size="40" maxsize="50" /></p><p>Tool Link: <input type="text" name="tool_link" size="40" maxsize="150" /></p><p>Tool Category: <select name="tool_cat"> <option value="Inventory">Inventory</option> <option value="Network Tools">Network Tools</option> <option value="Reference">Reference</option> <option value="User Account Tools">User Account Tools</option> <option value="Web Tools">Web Tools</option> </select></p><input type="submit" name="submit" value="Add Tool" /></form>[/code]If I wanted to check to see that tool_icon ends with .gif how would I do that and if it doesn't end in .gif where would I echo to the use to please end tool icon name with .gif. Quote Link to comment https://forums.phpfreaks.com/topic/5632-testing-to-see-if-a-string-ends-in-gif/ Share on other sites More sharing options...
craygo Posted March 23, 2006 Share Posted March 23, 2006 you want to check BEFORE the form is submited corect?? Quote Link to comment https://forums.phpfreaks.com/topic/5632-testing-to-see-if-a-string-ends-in-gif/#findComment-20129 Share on other sites More sharing options...
jimmyelewis Posted March 23, 2006 Author Share Posted March 23, 2006 [!--quoteo(post=357781:date=Mar 23 2006, 05:23 PM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ Mar 23 2006, 05:23 PM) [snapback]357781[/snapback][/div][div class=\'quotemain\'][!--quotec--]you want to check BEFORE the form is submited corect??[/quote]Yes, because it adds the icon name to a mysql database. Quote Link to comment https://forums.phpfreaks.com/topic/5632-testing-to-see-if-a-string-ends-in-gif/#findComment-20132 Share on other sites More sharing options...
High_-_Tek Posted March 23, 2006 Share Posted March 23, 2006 [code]if (pregi_match(".gif$", $_POST['tool_icon'])){$ok=TRUE;}else{$ok=FALSE;}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5632-testing-to-see-if-a-string-ends-in-gif/#findComment-20144 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.