Php Get and post function not working [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I make a simple app without any database in php .just simple post method when i write my input text field and submit it send me to another post and put that input data in that field where i want if work in xammp fine but on live server it show me nothing here is my codes.........
<form action='show.php' method='POST'>
<input type="text" size="30" value="Enter Your Course Code Like &nbsp
&nbsp 'CS101'..." name="text" >
<button name="submit"></button>
</form>
and my show.php code is
<?php
if(isset($_POST['submit'])){
$N = $_POST["text"];
echo ''.$N.'_movie';
}
?>
Where i am wrong?

add type <button name="submit" type="submit"></button>
Tip: Always specify the type attribute for a element. Different browsers use different default types for the element.
also remove name="submit"

You used html element button. It is good choice if you want to add any event with javascript. But if you need to send form normal with backend, you need to use
<input type="submit" value="send" />
OR
<button type="submit">send</button>
the type="submit" mark button as submit form button. You ommited the type so you created only button element.Equivalent for button is
<input type="button" value="Click me" onclick="msg()">
But button does'n invoke send form to the backend.

I think $_POST['submit'] is not set because it doesn't have a value.
Change:
<button name="submit"></button>
To:
<button name="submit" value="1">Submit</button>
Usually you would use a type="submit", then to set the button text you use value:
<input type="submit" value="Submit" />
And now $_POST["submit"] automatically has a value already.

Related

Clear form fields after submission [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
this is my first question!
I'm working on a simple email spoofer, but the problem is, when you click the submit button, the form fields save the originally entered values, and that means you can spam someone with tons of the same email easily by either pressing the submit button a lot or refreshing the page.
I would like some assistance.
Index.php - http://pastebin.com/dWp5V9vW
Mail.php - http://pastebin.com/DdZs8Rhq
That's because you're dropping the submitted field data into the HTML elements using PHP.
Here is the form HTML without the PHP extras.
<form action="index.php" method="POST">
<input type="text" name="from" placeholder="From" value="">
<input type="text" name="to" placeholder="To" value="">
<input type="text" name="subject" placeholder="Subject" value="">
<textarea name="body"></textarea>
<input type="submit" name="submit" value="Sent">
</form>
Just replace it in your index.php file.
Edit: If you're feeling a bit lazy, I did it for you: http://pastebin.com/XDZyva5T

How do I use PHP to create a dynamic answer based on a users input from a form? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I basically want to create a simple text input with a button that says submit. And using PHP I want to be able to give a different answer based on what the users input was. For example, if the user inputs the number 6, I want it to display "You are on week 6" - Can someone help me? I am having some trouble putting this together to get it to work.
The simple version is something like this:
<?php
echo "You are on week".$_POST['week'];
Your form would look like:
<form method="post">
<input name="week" />
<input type="submit" value="Submit" />
</form>
But it's much more complicated than this; you have to validate the input and worry about injection attacks, among other things.
You will get better help on here if you provide some code that you already have in place and ask specific questions about particular problems.
When your form is
<form method="post">
<input name="nameOfYourInput"/>
<input type="submit" value="sendButton"/>
</form>
This doesn't depend on serverside language be it php or any other language.
Specific to php is only the printing of the variable in the input field.
which can be achieved by
<?php
echo "You are on week" . $_POST['nameOfYourInput'];
The $_POST is variable which is passed(automaticaly) to the server with the http request.

HTML Form not submitting [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a form like follows:
<form action="" method="GET" data-ronsor-url="http://web-search.tk">
<input id="q">
<input type="submit" value="search">
</form>
But nothing is submitted.
if the form was at http://web-search.tk/?q=mysearch, when the form is submitted, the url is http://web-search.tk/?, why is this. It worked before.
Note: I will delete this question if I get more than 1 downvotes
You need to specify the form action and the name of the input (query) field (instead of, or in addition to, the id):
<form action="http://web-search.tk" method="GET">
<input name="q">
<input type="submit" value="search">
</form>
Try adding a name attribute to the form input:
<form action="" method="GET" data-ronsor-url="http://web-search.tk">
<input id="q" name="q">
<input type="submit" value="search">
</form>
I am not quite sure what are you trying to achieve but if you set the action attr = http://web-search.tk it performs the search at http://web-search.tk website.
You might be depending on some js if you wish to perform the search at your website, but again I'm not quite sure what's yor goal!
Good luck, hope it helps

Why is't my form working in php/html? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
im trying to pass a variable with a submit button and it doesn't work.
<FORM METHOD="LINK" ACTION=<?php echo "\"add_event.php?email=".$email."\""?>>
<INPUT TYPE="submit" VALUE="add event">
</FORM>
$email is fine in the page that's calling it.
http://localhost/aproject/add_event.php?
that is the url that's passed.
not
http://localhost/aproject/add_event.php?email=myemail#email.com
as I want.
Any thoughts are appreciated.
edit:
the generated html is
<form method="LINK" action="add_event.php?email=closeded#gmail.com">
<input type="submit" value="add event">
</form>
There is no such form method as LINK, so your form is using GET (the default).
When you submit a GET form, you will destroy any existing query string on the form action and replace it with one generated from the form data.
Use a hidden input to store your data instead.
<form action="add_event.php">
<input type="hidden" name="email" value="<?php echo htmlspecialchars($email); ?>">
<input type="submit" VALUE="add event">
</form>

how to show the hidden data from mysql database [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
<form name="form11" method="post" action="hpdata.php" enc type="multipart/form-data">
<input name="pro" id="pro" type="hidden" value= "CMS" />
<input name="piror" id="piror" type="hidden" value= "P1" />
<input name="stat" id="stat" type="hidden" value= "In Progress" />
<input type="submit" name="submit" id="submit" class="groovy button" value="...">
</form>
in this code I can't see the data
hidden attribute just use for hide item from the UI. but still you can acsess them after form is submitted using $_POST['id here'] (if form method is get you should get it through $_GET[])
the code you provided has nothing to do with mysql.
It is a html fragment. It contains hidden inputs. If you want to make them visible remove type="hidden".
But most likely there is a purpose why they are hidden. Often this is done to keep values for different form pages or to present the user with pretty values, but send easier to handle versions to the server. (e.g. dates can have different formats in different countrys, but its easier to just send them in a standardized form --> this one would be in a hidden input.)

Categories