phpnoobie9 Posted March 7, 2008 Share Posted March 7, 2008 I have a form that I can enter in an image url: form <form action="test.php" method="post"> Submit Image Url: <input type="text" name="image2" size="45" /> Submit Image Url 2: <br> <input type="text" name="image2" size="45" /> <input type="submit" name="preview" value="Preview" /> </form> When I submit the url the php code below checks for it..the below is wrapped up in a isset submit. This page get's the information from the form and replaces the str_replace IMAGE1 or IMAGE2 with what I entered from the url form. What I want is when the image url 1 or image url 2 is empty I want it to echo nothing else I want to echo the string replacement with the img src tag. Can't seem to get it to work. $imageempty = "";//If no url was entered $image1 = $_POST['image1'];//Get url from form $image1a = "<img src=\"$image1\" width=100 height=100 >";//Insert url into image tag //If image 1 input box empty if (!empty ($image1)) { //If not empty show this $replace = str_replace ("IMAGE1",$image1a,$replace); } else { //If empty show this $replace = str_replace ("IMAGE2",$imageempty,$replace); } Quote Link to comment Share on other sites More sharing options...
phpnoobie9 Posted March 7, 2008 Author Share Posted March 7, 2008 Figured it out. 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.