Reputation:
Can anyone skillful with PHP please help me with this question?
I want to essentially, convert a link into a button instead. Here is the relevant part of the code.
Basically, when the user clicks a different link (which is not relevant here), PHP will then generate another link called "Add Event" (this is the relevant one). It is the second line of this code that I am struggling to convert:
index.php
if(isset($_GET['v'])){
echo "<a href='".$_SERVER['PHP_SELF']."?month=".$month."&day=".$day."&year=".$year."&v=true&f=true'>Add Event</a>";
if(isset($_GET['f'])){
include("eventform.php");
It is attached to this file as well:
eventform.php
<form name='eventform' method='POST' action="<?php $_SERVER['PHP_SELF']; ?>?month=<?php echo $month;?>&day=<?php echo $day;?>&year=<?php echo $year;?>&v=true&add=true">
<table width='400px'>
<tr>
<td width='150px'>Title</td>
<td width='250px'><input type='text' name='txttitle'> </td>
</tr>
<tr>
<td width='150px'>Detail</td>
<td width='250px'> <textarea name='txtdetail'> </textarea> </td>
</tr>
<tr>
<td td colspan='2'align='center'> <input type='submit' name='btnadd' value='Add Event'> </td>
</tr>
</table>
</form>
Basically, when you click the "Add Event" link, a form is generated. I want to essentially turn the "Add Event" link into an "Add Event" button. It will serve the same purpose- when the button is clicked, a form is generated. Thank you to anyone who can help.
Upvotes: 0
Views: 103
Reputation: 41
You could style the anchor tag to look like a button.
On the second line of your code, add a class to the anchor element named btn like so:
<a class="btn" //rest of your code>
and then in your CSS file
.btn {
padding: 15px 30px;
color: white;
background: blue;
border-radius: 5px;
}
When it is rendered out to the view, it should have the appearance of a button.
Upvotes: 1