0
How do you make user input a variable in php?
8 odpowiedzi
+ 1
suppose you are using post method to provide user input , thn you will store it in varibles like this $variablename=$_POST ['input'];
+ 1
normally php is called from a Web page and is used to elaborate and print out the result. usually you pass variables with html form in get or post method, and u receive with $_GET["name"] or $_POST["name"]
+ 1
If you are using php cli then you can use stdin to take user Input
+ 1
It's very easy, in your user input page inside form you need to write code 👉 <input type="text" name="name"> and then you have to call your PHP script and in that you need to write code 👉 $name = $_POST["name"]; so that the name input by user will now stored in $name variable, you can check this by simply echo this , echo $name;
0
$_POST["input"]; 😉
0
Get value from html page
0
create a file index.php, paste the below code inside it and run it using xamp or wamp
code.
<!DOCTYPE html>
<html>
<body>
<form method="post" action="#">
First name:<br>
<input type="text" name="firstname">
<br>
Last name:<br>
<input type="text" name="lastname">
</form>
<?php
//Here is the php code to store the user input to the variable
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$fullname = "$firstname"." "."$lastname";//concatination with a space in between
echo $fullname;
?>
</body>
- 2
you must use mysql