I want to save the name="" part of this button
<button type="submit" class="btn grey large" id="taxicompany" name="<? echo $rows['company']; ?>">select</button>
So when i do this
<?php echo "".$_SESSION['POSTDATA']['taxicompany'].''; ?>
it displays the value of name=""
But it won't display?
Why do you not give the button a value
<button type="submit" class="btn grey large" id="taxicompany" name="taxicompany" value="<? echo $rows['company']; ?>">select</button>
Then when you submit your form and reference $_POST['taxicompany'] you will have the value
http://www.w3schools.com/tags/att_button_value.asp
Try this:
<form method="post">
<button type="submit" class="btn grey large" id="taxicompany" name="taxicompany" value="your company name">select</button>
</form>
// PHP code
if(isset($_POST['taxicompany']))
{
$_SESSION['POSTDATA']['taxicompany'] = $_POST['taxicompany'];
echo $_SESSION['POSTDATA']['taxicompany']; //your company name
}
Related
<form method="post>
<button input type="submit" id="click" class="btn btn-info " name="<?php echo$accept_request_id; ?>"></button>
</form>
Why can't I get value of $accept_request_id? I use following code
if(isset($_POST[$accept_request_id])) {
$accept_request_id=$_POST['accept_request_id'];
}
You can use below code to get value of form. This will work
<form method="post>
<input type="hidden" name="accept_request_id" value="<?php echo $accept_request_id ?>" />
<button input type="submit" id="click" class="btn btn-info">Submit
</button>
</form>
if(isset($_POST['accept_request_id'])) {
$accept_request_id = $_POST['accept_request_id'];
}
I want to pass a variable value to an url but the problem is when I first clicked the search button the value doesn't appear and when the second clicked is triggered the variable value is shown. How can i fix this? I think the fault is when i click the search button the page is refreshing. Can someone help me about this?
here's my code:
<div class="form-inline form-padding">
<form action="student.php?classid=<?php echo $classid;?>" method="post">
<input type="text" class="form-control" name="search" placeholder="Search by ID or Name">
<select name="subject" class="form-control" required>
<option value="">Select Subject...</option>
<?php while($row = mysql_fetch_array($mysubject)): ?>
<option value="<?php echo $row['id']?>" <?php if($row['id']==$classid) echo 'selected'; ?>><?php echo $row['subject'];?></option>
<?php endwhile; ?>
</select>
<button type="submit" name="submit" id="submit" class="btn btn-primary"><i class="fa fa-search"></i> Search</button>
<button type="button" name="submit" class="btn btn-success"><i class="fa fa-print"></i> Print</button>
</form>
</div>
in your
<form action="student.php?classid=<?php echo $classid;?>" method="post">
change it to
<form action="student.php" method="post">
Here are the codes.
Form
<form method="POST" action="" id="search">
<div class="col-lg-4 center"><a class="btn btn-success" type="submit" name="publish" id="publish" alt="Publish"> Publish</a></div>
<div class="col-lg-4 center"><a class="btn btn-success" type="submit" name="edit" id="edit" alt="Edit"> Edit </a></div>
<div class="col-lg-4 center"><a class="btn btn-success" type="submit" name="draft" id="draft" alt="Save as Draft"> Save as Draft</a></div>
</form>
Post
<?php
if ($_POST['publish'] == 'publish'){
echo '<script>alert("Publish"); </script>';
}
if ($_POST['edit'] == 'publish'){
echo '<script>alert("edit"); </script>';
}
if ($_POST['draft'] == 'publish'){
echo 'draft';
}
?>
If I click on any button nothing happens. I am not getting anything nor any error. Nothing appears in firebug as well.
You wanted to submit to the same page. Try giving the page name in your action
<form method="POST" action="yourpage.php" id="search">
Try with this:
<?php
if (isset($_POST['publish'])) {
echo '<script>alert("Publish"); </script>';
}
if (isset($_POST['edit'])) {
echo '<script>alert("edit"); </script>';
}
if (isset($_POST['draft'])) {
echo 'draft';
}
?>
use button instead of links
like
<input type="submit" ..... />
like this
<input type="submit" class="btn btn-success" name="publish" id="publish" alt="Publish" value="Publish" />
You will get data then
and try to on error reporting in php.ini file
You need to add a submit n
Button. <input type=submit name="submit"> also, specify action attribute in form tag to your Php script.
<?php
if (isset($_POST['submit'])){
echo '<script>alert("Publish"); </script>';
}
?>
<form method="POST" action="" id="search">
<input name="submit" type="submit" />
</form>
First thing you can not use type="submit" as attribute in your anchor tag.
Second if you wants to submit button using input type as submit then use the following code:
<?php
if(isset($_POST))
{
if (isset($_POST['publish'])){
echo '<script>alert("Publish"); </script>';
}
if (isset($_POST['edit'])){
echo '<script>alert("edit"); </script>';
}
if (isset($_POST['draft'])){
echo '<script>alert("Draft"); </script>';
}
}
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="search">
<div class="col-lg-4 center"><input class="btn btn-success" type="submit" name="publish" id="publish" value="Publish"> </input></div>
<div class="col-lg-4 center"><input class="btn btn-success" type="submit" name="edit" id="edit" value="Edit"> </input></div>
<div class="col-lg-4 center"><input class="btn btn-success" type="submit" name="draft" id="draft" value="Draft"> </input></div>
</form>
Third, In case if you really wants to use only anchor for submit then you have to use help of javascript function submit() and use the
onclick="document.getElementById('search').submit();
in your anchor tag.
<form method="post">
<button name="Day1" value="16">
<button name="Day2" value="32">
<input type="submit" value="Send">
</form>
I have some javascript that toggles the values of each button based on number of clicks
how do i catch values to submit as POST for backend handling
Regards,
H
Instead of incrementing the button values, increment the values of hidden inputs related to each button.
<form method="post">
<button type="button" onclick="this.nextElementSibling.value++;">Day1</button>
<input type="hidden" name="Day1" value="0">
<button type="button" onclick="this.nextElementSibling.value++;">Day2</button>
<input type="hidden" name="Day2" value="0">
<input type="submit" value="Send">
</form>
This way they can easily be submitted with your form.
I am new to PHP and I am trying to get information from a form to another page, but the data won't transfer over when I hit submit. What am I doing wrong? Should I be trying to use GET instead of POST? What is the best way to debug something like this?
The path to information.php is definitely correct.
<form action="information.php" method="post" type="post">
<div class="row" style="padding-bottom: 20px;">
<label name="tempID"><?php echo $number; ?></label>
<button class="btn" name="submit" type="submit">More Details</button>
</div>
</form>
This file is in a different page (information.php)
if (isset($_POST["tempID"]))
{
$infoID = $_POST['tempID'];
}
echo $infoID;
<input type="hidden" name="tempID" value="<?php echo $number; ?>" />
Add this next to your original echo, post variables can't be stored in a label. Also remove the name value from the label
You need a submit input instead of a button with the name submit. Change the button's html to:
<input type='submit' value='More Details'>
Change Label in input
<form action="information.php" method="post">
<div class="row" style="padding-bottom: 20px;">
<input name="tempID" value="<?php echo htmlentities($number); ?>"/>
<button class="btn" name="submit" type="submit">More Details</button>
</div>
</form>
labels are only to display information. they are not submitted during form submission.
<form action="information.php" method="post" type="post">
<div class="row" style="padding-bottom: 20px;">
<label>Number:</label>
<input name="tempID" value="<?php echo $number; ?>"/>
<input class="btn" id="submit" name="submit" type="submit" value="More Detail" />
</div>
</form>