Jump to content


Photo

Testing to see if a string ends in .gif


  • Please log in to reply
3 replies to this topic

#1 jimmyelewis

jimmyelewis
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 23 March 2006 - 09:44 PM

Hey,

I have the following 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>

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.

#2 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 23 March 2006 - 10:23 PM

you want to check BEFORE the form is submited corect??

#3 jimmyelewis

jimmyelewis
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 23 March 2006 - 10:44 PM

[!--quoteo(post=357781:date=Mar 23 2006, 05:23 PM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ Mar 23 2006, 05:23 PM) View Post[/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.

#4 High_-_Tek

High_-_Tek
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 23 March 2006 - 11:20 PM

if (pregi_match(".gif$", $_POST['tool_icon'])){
$ok=TRUE;
}else{
$ok=FALSE;
}








0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users