why cant i get value of $accept_request_id - php

<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'];
}

Related

REst API for Uploading Files

Can anyone help me how to use this function below... This function will upload file into to my storage but unfortunately I didn't know how to use the code. i tried numerous times already but still it doesn't work. This code is not mine I got it from github and try to use it into my project.
public function upload(){
// Check that the path is a directory
if(is_file($this->path)){
$this->status = "error";
$this->message = "Path Not A Directory";
}else{
// Handle upload
$target = $this->path . "/" . basename($_FILES['upload']['name']);
if(move_uploaded_file($_FILES['upload']['tmp_name'], $target)) {
$this->status = "success";
}else{
$this->status = "error";
$this->message = "Upload Error";
}
}
$this->respond();
}
<form action="file.php" method="get">
<input type="hidden" name="action" value="upload" readonly>
<input type="hidden" name="path" value="class/" readonly>
<input type="file" name="upload" readonly>
<!-- <input type="submit" name="create" class="btn btnsuccess btn-
sm" value="create dir/file ">
<input type="submit" name="open" class="btn btn-success btn-sm"
value="Open a file">
-->
<input type="submit" class="btn btn-success btn-sm" value="upload to specific dir">
<!-- <input type="submit" name="modify" class="btn btn-success
btn-sm" value="modify file or dir">
<input type="submit" name="delete" class="btn btn-success btn-sm"
value="delete file">
<input type="submit" name="index" class="btn btn-success btn-sm"
value="list dir">
<input type="submit" name="dublicate" class="btn btn-success btn-
sm" value="duplicate"> -->
</form>
url: http://localhost/api/archiving%20system/file.php?action=upload&path=class%2F&upload=myfile.txt
OUtput: {"status":"error","message":"Upload Error"}
You need the enctype="multipart/form-data" added to your <form> tag - and it should probably be POST for the method and not GET, and a max file size...
<form action="file.php" method="POST" enctype="multipart/form-data" >
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input type="hidden" name="action" value="upload" readonly>
<input type="hidden" name="path" value="class/" readonly>
<input type="file" name="upload" readonly>
<input type="submit" class="btn btn-success btn-sm" value="upload to specific dir">
</form>

Here variable 'pass' can't parse to $_post['action']=='edit'

<form action="" method="post">
<div class="col-md-2 ">
<input type="type" value="<?php echo $row['rcode'];?>" name="pass" id="pass"/>
<input type="submit" name="edit" class="btn btn-primary" value="edit"/>
<input type="submit" name="delete" class="btn btn-danger" value="Delete"/>
</div>
</form>
then
if($_POST['action']=='edit'){
echo $rcode1=$_REQUEST['pass'];
$sqlup="select * from transport_details where rcode='$rcode1'";
There is no input named action. Your current code is unreachable.
The $_POST assoc gets its keys by attribute name. E.g.
<input type="text" name="authorName" />
<?php
echo $_POST['authorName'];
?>
Your code should be like (in PHP file)
if (isset($_POST['edit'])) { ... }
OR (in HTML file)
<form action="" method="post">
<div class="col-md-2 ">
<input type="type" value="<?php echo $row['rcode'];?>" name="pass" id="pass"/>
<input type="submit" name="action" class="btn btn-primary" value="edit"/>
<input type="submit" name="action" class="btn btn-danger" value="Delete"/>
</div>
</form>
You can do this in your php...
if (isset($_POST['edit'])) {
echo $rcode1=$_POST['pass'];
$sqlup="select * from transport_details where rcode='".$rcode1."'";
}
assuming your html is like this...
<form action="" method="post">
<div class="col-md-2 ">
<input type="type" value="<?php echo $row['rcode'];?>" name="pass" id="pass"/>
<input type="submit" name="action" class="btn btn-primary" value="edit"/>
<input type="submit" name="action" class="btn btn-danger" value="Delete"/>
</div>
</form>
you should be able to get the value

I am not able to post form on same page

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.

PHP Session won't save unique value

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
}

How to add a $variable to a onclick="location.href='

Hi i need help because this is not working:
I just wanted to open websites with buttons but in a search box.....
<html>
<body>
<form>
<input type=button onClick=window.open("action.php","demo","width=550,height=300,left=150,top=200,toolbar=0,status=0,"); value="Öffne">
</form>
<form method="post" action="action.php">Suche: <input name="suche" type="text"><br>
<input type="submit" value="OK">
</form>
</body>
</html>
<php
$user = $_POST['suche'];
$seite = 'www.google.de/#q=';
$ziel=$seite.$user;
<form>
<input type=button onclick="location.href='https://www.google.de/#q=<?php echo $seite; ?>'" value='Website'>
<input type=button onClick="self.close();" value="Close this window">
</form>
You have more quotes missing on html tag attr and also php closing tags try
<html>
<body>
<form>
<input type="button" onClick='window.open("action.php","demo","width=550,height=300,left=150,top=200,toolbar=0,status=0,");' value="Öffne">
</form>
<form method="post" action="action.php">Suche: <input name="suche" type="text"><br>
<input type="submit" value="OK">
</form>
</body>
</html>
<?php
$user = $_POST['suche'];
$seite = 'www.google.de/#q=';
$ziel=$seite.$user;
?>
<form>
<input type="button" onclick="location.href='https://www.google.de/#q=<?php echo $seite; ?>'" value='Website'>
<input type="button" onClick="self.close();" value="Close this window">
</form>
Now I have a last question, I want to put both files index.html and action.php in one file. So if I go on Index.html i just have to enter my value for 'suche' and klick on submit button ('ok') to save the value of 'name' into '$input' and then klick on one of the buttons google,proxer,.... to search on that websites.
(maybe if it is possible I can merge the submit btton ('OK') and the buttons (google,proxer,...) to make it cleaner)
For example the link for google + $input would be: $seite_google.$input;
My code now looks like:
For index.php:
<?php
$input = $_POST['suche'];
$seite_google = 'https://www.google.de/#q=';
$seite_myanimelist = 'http://myanimelist.net/anime.php?q=';
$seite_anisearch = 'http://de.anisearch.com/anime/index/?char=all&text=';
$seite_proxer = 'http://proxer.me/search?name=';
?>
<form>
<input type="button" onclick="location.href='<?php echo $seite_google.$input; ?>'" value='Google Suche'>
<input type="button" onclick="location.href='<?php echo $seite_myanimelist.$input; ?>'" value='MyAnimeList'>
<input type="button" onclick="location.href='<?php echo $seite_anisearch.$input; ?>&q=true'" value='AniSearch'>
<input type="button" onclick="location.href='<?php echo $seite_proxer.$input; ?>&sprache=alle&typ=all&genre=&nogenre=&sort=name&length=&length-limit=down#search'" value='Proxer'>
</form>
<html>
<body>
<form method="post" action="">Suche: <input name="suche" type="text"><br>
<input type="submit" value="OK" name="submit">
</form>
</body>
</html>

Categories