Code Does Not Work But Should?

Hi,

I have the following code however it does not work on my site but I have seen it on other sites.

It is supposed to be a submit button. Can anyone advise if the DOCTYPE is correct?

<div class="aboutuscontent">
<div class="followbuttonbox">
<form>
<input name="followbutton" type="image" src="07221802_d18fc66228740e19b32cd5c95c8b4502.png" />
</div>
</form>
</div>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />

Justlukeyou,

I notice that you have some classes (i.e. aboutuscontent and followbuttonbox). Do you have a css style sheet linked to your HTML document that contains those classes? Also, are you sure that the image for your button is on your server? I would check those things first. If you can provide a link to the page where the code is installed I might be able to help you further.

Best,

Shawn

Many thanks,

I am trying to use an image as a submit button, the top line works but the bottom line doesn’t.

Can anyone advise how to use an image as a submit button?

<input name="followbutton" type="submit" />
<input name="followbutton" type="image" src="/images/follow.png" />

You are using the correct way to define an image as the submit button.

Just exactly what is happening that indicates that it is not working.

Is the image displaying? If not then the path to the image is wrong.

If you click on the image then the form will be submitted - if it isn’t then one of the validation tests that you are doing must be wrong.

It is usually best to not name submit buttons/images at all as the information passed is not useful - particularly when using images where both followbutton.x and followbutton.y will be zero if the form is submitted from the keyboard and will only contain values indicating a position within the image if the form is submitted by clicking on the image.

Thanks,

The image displays but when I click it nothing happens.

Is there a way of using images as a submit button?

Justlukeyou,

A better way to do this would be as follows:

This goes in your HTML

<div id=followbutton>
<input type=“submit” id=“image-button”>Text</input>
</div>

This Goes in a CSS File

#followbutton input{
background: #fff url(’ /images/follow.png’)no-repeat;
}

Best,

Shawn

Hi,

I tried this but I couldn’t get it to work. It displays the word “sumit” and the image on top of one another.

Yes - exactly as you are doing - at least for the part of the code that you are showing us.

If it isn’t working then the problem is in a part of the code you haven’t shown us.

Thanks,

This is all the code. I just cant see why it works with standard submit button but not an image. Its driving me nuts.

&lt;form method="post" enctype="multipart/form-data"&gt;

&lt;?php

$profileid = (int)$_GET['ID'];
$followerid = intval($_SESSION['userID']);



$query = mysql_query("SELECT * FROM follow WHERE user_id = '". $profileid ."' AND follow_user_id= '". $followerid ."'");
$duplicatefollow = null;
if (mysql_num_rows($query) &gt; 0)
{
$error['duplicatefollow'] = 'You Already Follow This Profile.&lt;/a&gt;.';
}

else
{

if(isset($_POST['followbutton'])) {


$query = "INSERT INTO `follow` (`user_id`, `follow_user_id`) VALUES ('{$profileid}', '{$followerid}')";
$result = mysql_query($query);


	if (!$result){
	$errors[] = "Query: {$query}&lt;br&gt;Error: " . mysql_error();
	}
       if(($profileid) == ($followerid)) {
$errors['sameprofile'] = "You cannot follow your own profile.";
}
}
}




  $loginprofile = intval($_SESSION['userID']);

  $query_rsSearch = "SELECT * FROM follow WHERE `follow_user_id` = '$loginprofile'";
$rsSearch = mysql_query($query_rsSearch) or die(mysql_error());
$row_rsSearch = mysql_fetch_assoc($rsSearch);
$totalRows_rsSearch = mysql_num_rows($rsSearch);

?&gt;



&lt;div class="followbuttonbox"&gt;
&lt;input name="followbutton" type="submit" /&gt;
&lt;input name="followbutton" type="image" src="/images/follow.png" /&gt;
&lt;/div&gt;
&lt;/form&gt;