+ 1
How to make a input box which takes input and print the same input in next line using php
Hello, I am new to this HTML, php and web, I wanna print same output which we enter in the box. Please help me how to do this in php
4 ответов
+ 3
Learning to use forms is a big part of php and html. You can use them to create login and sign up forms, get user feedback, send messages within you website, tons of stuff.
So all data collected inside the <form> and the </form> tags are sent to either a different file or itself by the action attribute, leaving it blank will send it to the file the form is in.
The method attribute describes the way or "method" by which it is sent, POST or GET
NEVER EVER SEND PASSWORDS, EMAILS, OR ANYTHING SENSITIVE with the GET method, only POST. So what you're wanting to do, its okay to use the GET method.
Inside the php code below, the $input variable collects the data inside the URL sent by the GET method, remember what method you use! To get the data inside the variable, use
$_GET["nameOfWhateverYouAreCollecting"]
or as a real example:
$_POST["username"]
$_POST["password"]
and assign a variable to this and you can do whatever you want with it.
The full(and should be working) code is below, hope I could help and have fun with it!
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<form action="" method="GET">
<input name="testInput"> </input>
<button type="submit"> Click </button>
</form>
<?php
$input = $_GET["testInput"];
echo $input;
?>
</body>
</html>
+ 2
okay, I just sent an email to you
+ 2
nice, now I have to delete my mail from comment
+ 2
hahaha definitely