Reputation: 19
I would like the Php script print to the screen all the values it gets from the html page.
This is the HTML code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
<title>Insert title here</title>
</head>
<body>
<div>
<form enctype="multipart/form-data" action="rect.php" method="post">
<label>Name:</label><input type="text" name="name"><br />
<label>Family Name:</label><input type="text" name="family"><br />
<label>Age:</label><input type="text" name="age"><br />
<input type="button" value="Print">
</form>
</div>
</body>
</html>
//And this is the PHP code:
<?php
$name = $_REQUEST['name'];
$family_name = $_REQUEST['family'];
$age = $_REQUEST['age'];
print $name.$family_name.$age;
?>
Upvotes: 0
Views: 179
Reputation: 576
You don't need the enctype if you're just sending text to the PHP form.
Your button must be type="submit"
and you should use $_POST since clearly you used it for the form.
Upvotes: 0
Reputation: 3821
First and foremost: Use $_POST
. Using $_REQUEST
is bad practice.
<?php
$name = $_POST['name'];
$family_name = $_POST['family'];
$age = $_POST['age'];
print $name.$family_name.$age;
?>
And your button doesn't submit. Make it this:
<input type="submit" value="Print">
Upvotes: 2
Reputation: 7762
change
<input type="button" value="Print">
to
<input type="submit" value="Print">
Upvotes: 0
Reputation: 5324
The $_REQUEST should work, your button however is a useless one.
<input type="button" value="Print">
should be
<input type="submit" value="Print">
And that should do the trick :)
Upvotes: 2