I have a blog I am building with entries. I have a form with hidden variables to submit the entryID and other data to "delete" the post. The button always shows below the entry, instead of beside it.
I have tried using CSS Clear, and putting everything in a single <p> line to see if that helps. I feel like the issue is that there is a form with hidden variables, but I'm not sure how to fix this.
<div id="subformposts">
<?php echo $subentry['Body']; ?>
<?php echo $subentry['CreateDate']; ?> - <?php echo $subentry['UserName']; ?><br />
<!-- Determine whether to show the delete button -->
<form action="Delete_entry.php" method="post" id="Deletesub<?php echo $subentry['EntryID'];?>" onsubmit="return confirmdelete('Deletesub<?php echo $subentry['EntryID'];?>')">
<input type="hidden" readonly="true" name="EntryID" value="<?php echo $subentry['EntryID']; ?>" />
<input type="hidden" readonly="true" name="UserID" value="<?php echo $subentry['UserID']; ?>" />
<?php if ($userid == 1 || $userid == $res['UserID']) { ?>
<input type="image" src="redx.png" alt="Delete Post" id="btnDelete" value="Delete Post" />
<?php } ?>
</form>
</div>
I want to see the button floating to the right of my entry, (or to the left at this point.) If I could have it tucked into the div that would be great.
You can use display: inline-flex on subformposts.
Like this one :
<div id="subformposts" style="display: inline-flex;">
<?php echo $subentry['Body']; ?>
<?php echo $subentry['CreateDate']; ?> - <?php echo $subentry['UserName']; ?><br />
<!-- Determine whether to show the delete button -->
<form action="Delete_entry.php" method="post" id="Deletesub<?php echo
$subentry['EntryID'];?>" onsubmit="return confirmdelete('Deletesub<?php echo $subentry['EntryID'];?>')">
<input type="hidden" readonly="true" name="EntryID" value="<?php echo $subentry['EntryID']; ?>" />
<input type="hidden" readonly="true" name="UserID" value="<?php echo $subentry['UserID']; ?>" />
<?php if ($userid == 1 || $userid == $res['UserID']) { ?>
<input type="image" src="redx.png" alt="Delete Post" id="btnDelete" value="Delete Post" />
<?php } ?>
</form>
</div>
Or you can keep both in two different div and put display:inline-block on both of those div. Like this .
<div id="subformposts" style="display: inline-block;">
<?php echo $subentry['Body']; ?>
<?php echo $subentry['CreateDate']; ?> - <?php echo $subentry['UserName']; ?><br />
</div>
<div style="display: inline-block;">
<!-- Determine whether to show the delete button -->
<form action="Delete_entry.php" method="post" id="Deletesub<?php echo
$subentry['EntryID'];?>" onsubmit="return confirmdelete('Deletesub<?php echo $subentry['EntryID'];?>')">
<input type="hidden" readonly="true" name="EntryID" value="<?php echo
$subentry['EntryID']; ?>" />
<input type="hidden" readonly="true" name="UserID" value="<?php echo
$subentry['UserID']; ?>" />
<?php if ($userid == 1 || $userid == $res['UserID']) { ?>
<input type="image" src="redx.png" alt="Delete Post" id="btnDelete" value="Delete Post" />
<?php } ?>
</form>
</div>
Related
I have created a simple form type page as follows,
<form action="" method="GET" >
<div class="input-group mb-3">
<input type="text" name="search" required value="<?php if(isset($_GET['search'])){echo $_GET['search']; } ?>" class="form-control" placeholder="Search data">
<button type="submit" class="btn btn-primary">Search</button>
</div>
</form>
I need to type a text in search box(name ="search") and after clicking submit I need to filter the sql data as follows.
<?php
$con = mysqli_connect("10.62.96.133", "root", "", "cdrextend");
if(isset($_GET['search']))
{
$filtervalues = $_GET['search'];
$query="***";
$query_run = mysqli_query($con, $query);
if(mysqli_num_rows($query_run) > 0)
{
foreach($query_run as $items)
{
?>
<tr>
<td><?= $items['***']; ?></td>
<td><?= $items['***']; ?></td>
</tr>
<?php
}
}
else
{
?>
<tr>
<td colspan="2">No Record Found</td>
</tr>
<?php
}
}
?>
Whenever I hit submit button after typing something in text box, it redirects to login page and I am not getting any results.Can someone show me where I have messed up?
Hi change your forms submit action="" to action="<?php echo htmlspecialchars($_SERVER[" PHP_SELF "]);?>"
<form action="<?php echo htmlspecialchars($_SERVER[" PHP_SELF "]);?>" method="GET" >
<div class="input-group mb-3">
<input type="text" name="search" required value="<?php if(isset($_GET['search'])){echo $_GET['search']; } ?>" class="form-control" placeholder="Search data">
<button type="submit" class="btn btn-primary">Search</button>
</div>
</form>
the website hoster upgraded tot php 7
the code
else{
$insert="Insert into voedselinfo(voedselnaam,Eenheid,Kcal,Eiwit,Koolh,Vet)
values('".$voedselnaam."','".$Eenheid."','".$Kcal."','".$Eiwit."','".$Vet."','".$Koolh."')";
$rs=mysql_query($insert) or die(mysql_error());
?>
<script>alert('Data Entry Saved!');</script>
<?php }
}
}
?>
does not work anymore....
should it be?
else{
$insert="Insert into voedselinfo(voedselnaam,Eenheid,Kcal,Eiwit,Koolh,Vet)
values('".$voedselnaam."','".$Eenheid."','".$Kcal."','".$Eiwit."','".$Vet."','".$Koolh."')";
$rs=mysqli_query($insert) or die(mysqli_error());
?>
<script>alert('Data Entry Saved!');</script>
<?php }
}
}
?>
but doesn't seem to work either, the alert doesn't show up anymore, nothing happens...
<!DOCTYPE html>
<head>
<title>Voedsel toevoegen bug 6</title>
<!-- Bootstrap -->
<link href="css/bootstrap.css" rel="stylesheet">
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<br><br>
<h3>Controleer dat de waarden correct naar het overzicht (View Data) worden overgezet.<h3>
<div class="left">
<form class="span4" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset>
<legend>Voedsel toevoegen</legend>
<label>voedselnaam<span class="required">*</span></label>
<input type="text" name="voedselnaam" class="input-xlarge" placeholder="voedselnaam" value="<?php if(isset($_POST['voedselnaam'])){ echo $_POST['voedselnaam']; }?>" autofocus>
<label>Eenheid<span class="required">*</span></label>
<input type="text" name="Eenheid" class="input-small" placeholder="" value="<?php if(isset($_POST['Eenheid'])){ echo $_POST['Eenheid']; }?>">
<br/>
<label>Kcal<span class="required">*</span></label>
<input type="text" name="Kcal" class="input-small" placeholder="" value="<?php if(isset($_POST['Kcal'])){ echo $_POST['Kcal']; }?>">
<br/>
<label>Eiwitten<span class="required">*</span></label>
<input type="text" name="Eiwit" class="input-small" placeholder="" value="<?php if(isset($_POST['Eiwit'])){ echo $_POST['Eiwit']; }?>">
<br/>
<label>Koolh.<span class="required">*</span></label>
<input type="text" name="Koolh" class="input-small" placeholder="" value="<?php if(isset($_POST['Koolh'])){ echo $_POST['Koolh']; }?>">
<br/>
<label>Vet<span class="required">*</span></label>
<input type="text" name="Vet" class="input-small" placeholder="" value="<?php if(isset($_POST['Vet'])){ echo $_POST['Vet']; }?>">
<?php
if(isset($_POST['getdata'])){
$conn=mysqli_connect('localhost','masked','masked01');
mysqli_select_db("database",$conn);
// $regexp = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[#][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/";
$voedselnaam=$_POST['voedselnaam'];
$Eenheid=$_POST['Eenheid'];
$Kcal=$_POST['Kcal'];
$Eiwit=$_POST['Eiwit'];
$Koolh.=$_POST['Koolh'];
$Vet=$_POST['Vet'];
$var=mt_rand(0,1);
if($var == 1 || 0) {
if($Vet >15 && $Eiwit >10)
{
echo "<label class='err'>You found bug#3: The system crashes by testing this way. Great Job!</label>";
}
elseif($Vet ==15 && $Eiwit ==10)
{
echo "<label class='err'>You found bug#4: Boundry value analyses. (only in combination of both boundry) Great Job!</label>";
}
elseif($Vet >15)
{
echo "<label class='err'>You found bug#2: Fat bigger then 15</label>";
}
elseif($Eiwit >10)
{
echo "<label class='err'>You found bug#1: Eiwit bigger then 10 </label>";
}
else{
$insert="Insert into voedselinfo(voedselnaam,Eenheid,Kcal,Eiwit,Koolh,Vet)
values('".$voedselnaam."','".$Eenheid."','".$Kcal."','".$Eiwit."','".$Vet."','".$Koolh."')";
$rs=mysql_query($insert) or die(mysql_error());
?>
<script>alert('Data Entry Saved!');</script>
<?php }
}
}
?>
<br/> <button type="submit" name="getdata" class="btn">Submit</button>
View Data
</fieldset>
</form>
</div>
<?php
function save(){
}
?>
</body>
</html>
I have two forms in html and i want to align their buttons next to each other. Unfortunately I've tried to merge them but then they don't work properly. Is their any way to that i can achieve that if possible without css?
Below is my code:
<form action="lorhs.php" method="GET" name="FormPage">
<button type="submit" id="backwards" <?php echo ($page == 1) ? "disabled" : ""; ?> style="float: left;" value="<?php echo $page-1; ?>" name="page">Prev</button>
<button type="submit" id="forward" <?php echo ($page == ceil($row['0']/25)) ? "disabled" : ""; ?> style="float: left;" value="<?php echo $page+1; ?>" name="page">Next</button>
</form>
<form method="GET" name="FormPage">
<select name="page" style="float: left;" onChange="document.forms['FormPage'].submit()">
<?php
for($i = 1, $size = ceil($row['0']/25); $i <= $size; $i++)
echo "<option ".($page == $i ? "selected " : "")."value='".$i."'>".$i."</option>";
?>
</select>
</form>
I figure it out. I just had to add <span style="float:left;"> </span> in each of my forms and delete style inside of them.
How can it be done to submit when i change radio button from On to Off or from Off to On. My HTML code is :)
<div class="centered3">
<div class="wrapper">
<form action="oralive-csv.php" method="post" name="fshi_shkruaj">
<td><input style="margin-bottom:10px; float:right;" type="submit" name="submit" value="Shko Live" /></td>
<table style="width:950px;">
<tr>
<th style="float:left;color:#900;">Titulli</th>
<th style="color:#900;">Nentitulli</th>
<th style="color:#900;">Live</th>
</tr>
<?php $i=0; foreach ($results as $result) : ?>
<tr>
<td style="padding-right:5px;height:1.5em;">
<input type="hidden" name="id<?php echo $i; ?>"value="<?php echo $result['id'] ?>" />
<input type="hidden" name="title<?php echo $i;?>"value="<?php echo htmlspecialchars($result['text'],ENT_NOQUOTES,'UTF-8');?>" />
<div class="textndrysho"><input style="font-size:16px;color:#000;width:200px;" type="text" name="title<?php echo $i;?>" value="<?php echo htmlspecialchars($result['text'],ENT_NOQUOTES,'UTF-8'); ?>" maxlength="32"/>
</td></div>
<td style="padding-right:5px;height:1.5em;">
<input type="hidden" name="id<?php echo $i; ?>"value="<?php echo $result['id'] ?>" />
<input type="hidden" name="subtitle<?php echo $i;?>"value="<?php echo htmlspecialchars($result['subtext'],ENT_NOQUOTES,'UTF-8');?>" />
<div class="textndrysho"><input style="font-size:16px;color:#000;width:400px;" type="text" name="subtitle<?php echo $i;?>" value="<?php echo htmlspecialchars($result['subtext'],ENT_NOQUOTES,'UTF-8'); ?>" maxlength="45"/>
</td></div>
<td style="padding-right:5px;height:1.5em;">
<input type="hidden" name="id<?php echo $i; ?>"value="<?php echo $result['id'] ?>" />
<input type="hidden" name="vendi<?php echo $i;?>"value="<?php echo htmlspecialchars($result['vendi'],ENT_NOQUOTES,'UTF-8');?>" />
<div class="textndrysho"><input style="font-size:16px;color:#000;width:120px;" type="text" name="vendi<?php echo $i;?>" value="<?php echo htmlspecialchars($result['vendi'],ENT_NOQUOTES,'UTF-8'); ?>" maxlength="12"/>
</td></div>
<td>
<label><input type="radio" name="shfaq<?php echo $i; ?>" value="1" id="radiobuttonsondazh_0" <?php if($result['live']==1) echo 'checked'; ?> onclick="document.getElementById('myForm').submit();" />Po</label>
<label><input type="radio" name="shfaq<?php echo $i; ?>" value="0" id="radiobuttonsondazh_1" <?php if($result['live']==0) echo 'checked'; ?> onclick="document.getElementById('myForm').submit();" />Jo</label>
</td>
<td>
<input type="checkbox" name="chk<?php echo $i; ?>" >Fshi
</td>
</tr>
<?php $i = $i+1;
endforeach;
?>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><input style="margin-top:26px;" type="submit" name="submit" value="Shko Live" /></td>
</tr>
</table>
<input type="hidden" value="<?php echo $i = $i-1; ?>" name="saka" /> </form>
</div>
</div></center>
I have try it to onChange Submit this form but not lucky. :(
Can anyone please help me?
You may need to use some javascript it has special what they call event handlers. onclick, blclick, etc. There is a way to have javascript and php code mixed together. Maybe this would work. Also what do you want this form to do that way I can help you more easily.
function dosomething()
{
var formelement = document.getElementById['theid'].value; //retrieves the value from the form element
if (formelement == "whatever")
{
window.open("http://www139.net63.net"); //opens a url in a window
}
else
{
alert("This is a popup window");
}
}
====================
<input type="radio" name="whatever" id="theid" value="your value, url etc." onclick="dosomething()">
I'd like to show this div with a "add to cart" button IF the price contained in $row_thumbs['Listino 9'] is not empty. How can that be accomplished? Jquery?
<div id="button" style="padding: 10px 0px 10px 0px;">
<form name="eCart1_1_ATC_<?php echo $row_thumbs["Cod."]; ?>" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".$_SERVER["QUERY_STRING"]:""; ?>">
<input type="hidden" name="eCart1_1_ID_Add" value="<?php echo $row_thumbs["Cod."]; ?>" >
<input type="hidden" name="eCart1_1_Quantity_Add" value="1" size="2" >
<input type="image" src="images/acquista.png" width="95" border="0" class="eC_ImageButton" value="Aggiungi al carrello" name="eCart1_1_ATC"></form>
</div>
uncomment the first line, then the BUTTON will be showed, make sure the script runs on a server and also I would never make spaces $row_thumbs['ListinoHERE9']
<?php
//$row_thumbs['Listino_9']='cheater';
if($row_thumbs['Listino_9']!='') {
echo '<div class="button"> B U T T O N</div>';
}
?>
<style type="text/css">
.button {
padding:5px;
width:100px;
background-color:gray;
}
.button:hover {
cursor:pointer;
background-color:orange;
}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.button').click(function(){
$('.show-div-if-button-gets-clicked').toggle();
});
});
</script>
<div class="show-div-if-button-gets-clicked" style="display:none;">
<form name="eCart1_1_ATC_<?php echo $row_thumbs["Cod."]; ?>" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".$_SERVER["QUERY_STRING"]:""; ?>">
<input type="hidden" name="eCart1_1_ID_Add" value="<?php echo $row_thumbs["Cod."]; ?>" >
<input type="hidden" name="eCart1_1_Quantity_Add" value="1" size="2" >
<input type="image" src="images/acquista.png" width="95" border="0" class="eC_ImageButton" value="Aggiungi al carrello" name="eCart1_1_ATC"></form>
</div>