HI,
I wrote this code in php.
<head>
<title>listent</title>
</head>
<body>
<form action="untitled 3.php">
<input type = "text" name = "user">
<br>
<textarea name = "address" rows = "10" cols = "40">
</textarea>
<br>
<input type = "submit" value = "heat it">
<br>
<select name="combobox" multiple[]>
<option>mehdi
<option>nine
</select>
&l开发者_如何学运维t;/form>
</body>
</html>
now when i click on submit button untitled 3.php
is run.
in untitled 3.php i wrote
<?php
print "welcome $user";
?>
but it has error.
Notice: Undefined variable: user in C:\xampp\htdocs\me\Untitled 3.php on line 4
welcome
what is problem?how can i solve it?
Form values don't just magically appear as variables anymore - at least not in any decently modern and properly configured PHP installation. You need to do $_GET["user"]
to access the value which is sent by the form (into the URL - you might want to read about the difference between GET and POST)
And please, please use more descriptive names for your files...
PHP Globals wont survive the new page.
In you case you must use the POST variables sent by your form.
So in untitled3.php you should have
echo "welcome ".$_POST['user'];
PS : I would avoid spaces in PHP filenames.
First you should specify a Form submission method in your first page:
<form action="untitled 3.php" method="post">
Then you have access to all posted values in the $_POST
array in untitled 3.php
:
$user = $_POST['user'];
精彩评论