user2491321
user2491321

Reputation: 673

convert button of a form into a hyperlink

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?

Upvotes: 1

Views: 74

Answers (2)

Kumar V
Kumar V

Reputation: 8838

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

Upvotes: 2

voodoo417
voodoo417

Reputation: 12101

@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>

Upvotes: 2

Related Questions