About image buttons

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
emilcarlo
Forum Commoner
Posts: 43
Joined: Wed Jul 21, 2010 12:38 pm

About image buttons

Post by emilcarlo »

Good morning there,

One quick question. I have a working button with the code <input type="submit" name="btnSubmit" id="btnSubmit" value="Add Record" />. We all know that this code creates a button with Add Record in it. My question is, is it possible to create a button using image that should function just like the code posted? I know the question is noobie xD Please bear with me, I am still in the learning process. Thank you very much ^^
emilcarlo
Forum Commoner
Posts: 43
Joined: Wed Jul 21, 2010 12:38 pm

Re: About image buttons

Post by emilcarlo »

I have found out that I can simply change input type. However, the button does not function similar to what it should do. Please see the code:

Code: Select all

<link href="add_client.css" rel="stylesheet" type="text/css">

<?php
include("dbconnection.php");

if(isset($_POST["btnSubmit"]))
{
	$id = $_POST["id"];
	$date = $_POST["date"];
	$status = $_POST["status"];
	$territory = $_POST["territory"];
	$job_title = $_POST["job_title"];
	$area_of_work = $_POST["area_of_work"];
	$employer = $_POST["employer"];
	$department = $_POST["department"];
	$location = $_POST["location"];
	$date_posted = $_POST["date_posted"];
	$closing_date = $_POST["closing_date"];
	$gender = $_POST["gender"];
	$first_name = $_POST["first_name"];
	$last_name = $_POST["last_name"];
	$telephone = $_POST["telephone_number"];
	$title = $_POST["title"];
	$address_1 = $_POST["address_1"];
	$address_2 = $_POST["address_2"];
	$address_3 = $_POST["address_3"];
	$city = $_POST["city"];
	$country = $_POST["country"];
	$postal_code = $_POST["postal_code"];
	$website = $_POST["website"];
	$email_address = $_POST["email_address"];
	$comment_by_cg = $_POST["cg_comment"];
	$date_emailed = $_POST["date_emailed"];
	$mailing_comments= $_POST["mailing_comments"];
	$telesales_comments= $_POST["telesales_comments"];
	
	$query = "INSERT INTO records (date, status, territory, job_title, area_of_work, employer, department, location, date_posted, closing_date, gender, first_name, last_name, telephone_number, title, address_1, address_2, address_3, city, country, postal_code, website, email_address, cg_comment, date_emailed, mailing_comments, telesales_comments) VALUES ('".$date."','".$status."','".$territory."', '".$job_title."', '".$area_of_work."', '".$employer."', '".$department."', '".$location."', '".$date_posted."', '".$closing_date."', '".$gender."', '".$first_name."', '".$last_name."', '".$telephone_number."', '".$title."', '".$address_1."', '".$address_2."', '".$address_3."', '".$city."', '".$country."', '".$postal_code."', '".$website."', '".$email_address."', '".$cg_comment."', '".$date_emailed."', '".$mailing_comments."', '".$telesales_comments."')";
	
	mysql_query($query) or die(mysql_error());
	
	echo "<script>
		alert('You have successfully added a record');
		window.location = 'add_client.php';
	</script>";
}
?>

<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="760" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="199" align="center" valign="top"><a href="login.html"><img src="asia.gif" alt="" width="152" height="58" border="0" /></a></td>
        <td width="176" align="right" valign="bottom"><a href="main.html"><img src="Home.jpg" width="104" height="20" border="0"/></a></td>
        <td width="130" align="right" valign="bottom"><a href="view_client.html"><img src="View.jpg" width="104" height="20" border="0"/></a></td>
        <td width="146" align="right" valign="bottom"><img src="Add.jpg" width="104" height="20" border="0"/></td>
        <td width="109" align="right" valign="bottom">&nbsp;</td>
        </tr>

    </table></td>
  </tr>
  <tr>
    <td><table width="760" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="200" height="3"  bgcolor="#1B1C78"><img src="images/topspacerblue.gif" alt="" width="1" height="3" /></td>
        <td width="560"  bgcolor="#0076CC"><img src="images/topspacerlblue.gif" alt="" width="1" height="3" /></td>

      </tr>
    </table></td>

  </tr>
  <tr>
    <td height="526" align="center" valign="top" bgcolor="#F3FAFE"><p>&nbsp;</p>
      <form name="form" method="post" action="add_client.php">
      <table width="679" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="160" height="26" align="left" valign="middle" scope="col">Date and Time</td>
        <td width="160" height="26" align="center" valign="middle" scope="col">
		<?php
        $date = date("d/m/y");
		print date("d/m/y | h:i a", time()) 
		?>&nbsp;
        
</td>
        <td width="39" height="26" align="left" valign="top" scope="col">&nbsp;</td>
        <td height="26" colspan="2" align="left" valign="middle" scope="col">Status</td>
        <td height="26" colspan="2" align="center" valign="middle" scope="col">NEW RECORD</td>
      </tr>
      <tr>
        <td width="160" align="left" valign="middle" scope="col">Territory</td>
        <td width="160" height="27" align="center" valign="middle" scope="col"><select name="territory" style="width: 143px" id="territory">
          <option selected="selected" disabled="disabled">Select Territory</option></select></td>
        <td width="39" height="27" align="left" valign="top" scope="col">&nbsp;</td>
        <td colspan="2" align="left" valign="middle" scope="col">Location</td>
        <td height="27" colspan="2" align="center" valign="middle" scope="col"><input name="location" type="text" id="location" /></td>
      </tr>
      <tr>
        <td width="160" align="left" valign="middle" scope="col">Area of Work</td>
        <td width="160" height="26" align="center" valign="middle" scope="col"><input name="area_of_work" type="text" id="area_of_work" /></td>
        <td width="39" height="26" align="left" valign="top" scope="col">&nbsp;</td>
        <td colspan="2" align="left" valign="middle" scope="col">Job Title</td>
        <td height="26" colspan="2" align="center" valign="middle" scope="col"><input name="job_title" type="text" id="job_title" /></td>
      </tr>
      <tr>
        <td width="160" align="left" valign="middle" scope="col">Employer</td>
        <td width="160" height="27" align="center" valign="middle" scope="col"><input name="employer" type="text" id="employer" /></td>
        <td width="39" height="27" align="left" valign="top" scope="col">&nbsp;</td>
        <td colspan="2" align="left" valign="middle" scope="col">Department</td>
        <td height="27" colspan="2" align="center" valign="middle" scope="col"><input name="department" type="text" id="department" /></td>
      </tr>
      <tr>
        <td width="160" align="left" valign="middle" scope="col">Date Posted</td>
        <td width="160" height="26" align="center" valign="middle" scope="col"><input name="date_posted" type="text" id="date_posted" /></td>
        <td width="39" height="26" align="left" valign="top" scope="col">&nbsp;</td>
        <td colspan="2" align="left" valign="middle" scope="col">Closing Date</td>
        <td height="26" colspan="2" align="center" valign="middle" scope="col"><input name="closing_date" type="text" id="closing_date" /></td>
      </tr>
      <tr>
        <td width="160" height="27" align="left" valign="middle" scope="col">&nbsp;</td>
        <td width="160" height="27" align="center" valign="middle" scope="col">&nbsp;</td>
        <td width="39" height="27" align="left" valign="top" scope="col">&nbsp;</td>
        <td height="27" colspan="2" align="left" valign="middle" scope="col">&nbsp;</td>
        <td height="27" colspan="2" align="center" valign="middle" scope="col">&nbsp;</td>
      </tr>
      <tr>
        <td width="160" height="26" align="left" valign="middle" scope="col">First Name</td>
        <td width="160" height="26" align="center" valign="middle" scope="col"><input name="first_name" type="text" id="first_name" /></td>
        <td width="39" height="26" align="left" valign="top" scope="col">&nbsp;</td>
        <td height="26" colspan="2" align="left" valign="middle" scope="col">Last Name</td>
        <td height="26" colspan="2" align="center" valign="middle" scope="col"><input name="last_name" type="text" id="last_name" /></td>
      </tr>
      <tr>
        <td width="160" height="27" align="left" valign="middle" scope="col">Title</td>
        <td width="160" height="27" align="center" valign="middle" scope="col"><input name="title" type="text" id="title" /></td>
        <td width="39" height="27" align="left" valign="top" scope="col">&nbsp;</td>
        <td height="27" colspan="2" align="left" valign="middle" scope="col">Telephone Number</td>
        <td height="27" colspan="2" align="center" valign="middle" scope="col"><input name="telephone_number" type="text" id="telephone_number" /></td>
      </tr>
      <tr>
        <td width="160" height="27" align="left" valign="middle" scope="col">Address 1</td>
        <td width="160" height="27" align="center" valign="middle" scope="col"><input name="address_1" type="text" id="address_1" /></td>
        <td width="39" height="27" align="left" valign="top" scope="col">&nbsp;</td>
        <td height="27" colspan="2" align="left" valign="middle" scope="col">Address 2</td>
        <td height="26" colspan="2" align="center" valign="middle" scope="col"><input name="address_2" type="text" id="address_2" /></td>
      </tr>
      <tr>
        <td width="160" height="26" align="left" valign="middle" scope="col">Address 3</td>
        <td width="160" height="26" align="center" valign="middle" scope="col"><input name="address_3" type="text" id="address_3" /></td>
        <td width="39" height="26" align="left" valign="top" scope="col">&nbsp;</td>
        <td height="26" colspan="2" align="left" valign="middle" scope="col">City</td>
        <td height="27" colspan="2" align="center" valign="middle" scope="col"><input name="city" type="text" id="city" /></td>
      </tr>
      <tr>
        <td width="160" height="27" align="left" valign="middle" scope="col">Country</td>
        <td width="160" height="27" align="center" valign="middle" scope="col"><input name="country" type="text" id="country" /></td>
        <td width="39" height="27" align="left" valign="top" scope="col">&nbsp;</td>
        <td height="27" colspan="2" align="left" valign="middle" scope="col">Postal Code</td>
        <td height="26" colspan="2" align="center" valign="middle" scope="col"><input name="postal_code" type="text" id="postal_code" /></td>
      </tr>
      <tr>
        <td width="160" align="left" valign="middle" scope="col">&nbsp;</td>
        <td width="160" height="26" align="center" valign="middle" scope="col">&nbsp;</td>
        <td width="39" height="26" align="left" valign="top" scope="col">&nbsp;</td>
        <td height="26" colspan="2" align="left" valign="middle" scope="col">&nbsp;</td>
        <td height="27" colspan="2" align="center" valign="middle" scope="col">&nbsp;</td>
      </tr>
      <tr>
        <td width="160" align="left" valign="middle" scope="col">Website</td>
        <td width="160" height="27" align="center" valign="middle" scope="col"><input name="website" type="text" id="website" /></td>
        <td width="39" height="27" align="left" valign="top" scope="col">&nbsp;</td>
        <td height="27" colspan="2" align="left" valign="middle" scope="col">Email Address</td>
        <td height="26" colspan="2" align="center" valign="middle" scope="col"><input name="email_address" type="text" id="email_address" /></td>
      </tr>
      <tr>
        <td width="160" align="left" valign="middle" scope="col">&nbsp;</td>
        <td width="160" height="27" align="center" valign="middle" scope="col">&nbsp;</td>
        <td width="39" height="27" align="left" valign="top" scope="col">&nbsp;</td>
        <td height="27" colspan="2" align="left" valign="middle" scope="col">&nbsp;</td>
        <td height="27" colspan="2" align="center" valign="middle" scope="col">&nbsp;</td>
      </tr>
      <tr>
        <td width="160" align="left" valign="middle" scope="col">CG Comment</td>
        <td width="160" height="26" align="center" valign="middle" scope="col"><input name="cg_comment" type="text" id="cg_comment" /></td>
        <td width="39" height="26" align="left" valign="top" scope="col">&nbsp;</td>
        <td height="26" colspan="2" align="left" valign="middle" scope="col">Date Emailed</td>
        <td height="26" colspan="2" align="center" valign="middle" scope="col"><input name="date_emailed" type="text" id="date_emailed" /></td>
      </tr>
      <tr>
        <td width="160" align="left" valign="middle" scope="col">Mailing Comment</td>
        <td width="160" height="27" align="center" valign="middle" scope="col"><input name="mailing_comment" type="text" id="mailing_comment" /></td>
        <td width="39" height="27" align="left" valign="top" scope="col">&nbsp;</td>
        <td height="27" colspan="2" align="left" valign="middle" scope="col">&nbsp;</td>
        <td height="27" colspan="2" align="left" valign="middle" scope="col"></td>
      </tr>
      <tr>
        <td align="left" valign="middle" scope="col">Telesales Comment</td>
        <td height="27" align="center" valign="middle" scope="col"><input name="telesales_comment" type="text" id="telesales_comment" /></td>
        <td height="27" align="left" valign="middle" scope="col">&nbsp;</td>
        <td width="49" height="27" align="center" valign="middle" scope="col"><img src="Delete.png" width="27" height="27" /></td>
        <td width="111" align="left" valign="middle" scope="col">Clear Fields</td>
        <td width="53" height="27" align="center" valign="middle" scope="col"><input type="image" src="Add.png" width="27" height="27" name="btnSubmit" id="btnSubmit"/></td>
        <td width="107" align="left" valign="middle" scope="col">Add Record</td>
      </tr>
      </table>
    </form></p></td>

  </tr>
  <tr>
    <td height="38"><table width="760" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="200" height="35" align="center"  bgcolor="#1B1C78" class=white><img src="images/topspacerblue.gif" alt="" width="1" height="3" />&nbsp;<a href="disclaimer.html"><font color="#FFFFFF">Legal Disclaimer</font></a> </td>

        <td width="560" align="center"  bgcolor="#0076CC"  class=white><img src="images/topspacerlblue.gif" alt="" width="1" height="3" />&nbsp;Copyright &copy; 2006 - 2010 Limited. All rights reserved.
</td>
      </tr>

    </table></td>
  </tr>
</table>
Last edited by Benjamin on Wed Jul 28, 2010 3:44 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
buckit
Forum Contributor
Posts: 169
Joined: Fri Jan 01, 2010 10:21 am

Re: About image buttons

Post by buckit »

so you just want the submit button to be an image?

thats simple.. <INPUT TYPE="image" SRC="images/submit.gif" />

type 'image' acts the same as type 'submit'

googles is your friend when learning this stuff... google also answers a lot faster! I just googled 'submit button image' and the first link gave the answer.
emilcarlo
Forum Commoner
Posts: 43
Joined: Wed Jul 21, 2010 12:38 pm

Re: About image buttons

Post by emilcarlo »

buckit wrote:so you just want the submit button to be an image?

thats simple.. <INPUT TYPE="image" SRC="images/submit.gif" />

type 'image' acts the same as type 'submit'

googles is your friend when learning this stuff... google also answers a lot faster! I just googled 'submit button image' and the first link gave the answer.
Thanks for this one, I did it already on my 2nd post, thanks to google. My problem now is it doesn't work similar with the type "submit"
emilcarlo
Forum Commoner
Posts: 43
Joined: Wed Jul 21, 2010 12:38 pm

Re: About image buttons

Post by emilcarlo »

Got it working now ^^
buckit
Forum Contributor
Posts: 169
Joined: Fri Jan 01, 2010 10:21 am

Re: About image buttons

Post by buckit »

what was your resolution?
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: About image buttons

Post by manojsemwal1 »

but in submit or button or image type one problem is there we can not get the name of button we can take only type=submit.in another case type=button and type=image it will not pass the button name. isset($_POST()) is fail here.


Thanks
emilcarlo
Forum Commoner
Posts: 43
Joined: Wed Jul 21, 2010 12:38 pm

Re: About image buttons

Post by emilcarlo »

This is my solution, and it worked ^^

<input type="image" src="Add.png" height="27" width="27" name="btnSubmit" id="btnSubmit" value="Add Record" />

I think I missed the name and Id. I just tried to check it one by one, and then it worked ^^
Post Reply