1

I have the following form in php:

<?php
<form action='deletepost.php' method='post'>
  <input type='hidden' name='var' value='$comment_id;'>
  <input type='submit' value='Delete'> 
</form>
?>

when the user press the delete button goes to deletepost.php script which is the following:

<?php  

$comment = mysql_real_escape_string($_POST['var']);

    if(isset($comment) && !empty($comment)){
    mysql_query("UPDATE `comments` SET `flag`=1 WHERE (`user`='$session_user_id' AND `comments_id`='$comment')");
    header('Location: wall.php');
}           

?>

I want the delete button that I have in my form to make it look a link. Any idea which is the best and easier way to do this?

user2491321
  • 673
  • 10
  • 32

2 Answers2

2

Assign a class to your submit button called "btn_link".

html:

<input type='submit' value='Delete' class='btn_link'> 

Then you can do with css

.btn_link
{
    background:none!important;
     border:none; 
     padding:0!important;    
     border-bottom:1px solid #444; /*border is optional*/
}

N.B.: See the comments below, regarding the use of !important

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Kumar V
  • 8,810
  • 9
  • 39
  • 58
  • 2
    `!important` is **evil** don't use, except when _really_ needed – jgabriel Jan 12 '14 at 16:22
  • Do explain. I for one have never heard that before. A link to a relevant page would be helpful. @jgabriel – Funk Forty Niner Jan 12 '14 at 16:23
  • 1
    @jgabriel Yes. However user may be added color to button. that is why i used important at last. – Kumar V Jan 12 '14 at 16:24
  • 1
    http://stackoverflow.com/questions/3706819/what-are-the-implications-of-using-important-in-css – jgabriel Jan 12 '14 at 16:25
  • 1
    Thanks for the link @jgabriel And here I thought it was a security-related issue (lol). I will admit that I use `!important` as a very last resort, which could be the 1 in 1000. – Funk Forty Niner Jan 12 '14 at 16:29
  • You're welcome! Usualy the use of `!important` can be avoiding by carefully organizing the structure of your CSS files. I use `!important` only in classes that i _really_ have to be sure that they will follow some order. Like `.hide{ display: none !important; }` – jgabriel Jan 12 '14 at 16:31
  • @jgabriel I've had some trouble in the past, where certain browsers didn't want to cooperate with each other, especially IE. IE has always been problematic for a lot of web designers. Even with current Web (W3) standards put in place, IE doesn't always want to "play the game", as it were. Cheers (I made a slight EDIT in the answer, in regards to this issue). – Funk Forty Niner Jan 12 '14 at 16:55
  • Another case where `!important` is valid -> CSS-hacking for IE :P – jgabriel Jan 12 '14 at 16:59
2

@kumar_v did it. Only for example (use real link):

<form action='deletepost.php' method='post'>
  <input type='hidden' name='var' value='$comment_id;'>
  <a onclick="javascript:this.parentNode.submit();">Delete</a>
</form>
voodoo417
  • 11,861
  • 3
  • 36
  • 40