开发者

T_VAR Error with PHP

i am working on an html form that sends data to a php file which displays it... eventually i will have the php send the data to a mysql database. when i submit my form, i get a php error:

Parse error: syntax error, unexpected T_VAR in /home2/rocksoli/public_html/webscan/trucheckupdates/mySQL-test/sql_submit.php on line 2

this is my html file:

<html>
<head>
<title>Webscan Test Form</title>
</head>
<body>
<form name="test" action="sql_submit.php" method="post">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="hidden" name="formname" value="test" />
<input type="submit" value="Submit" />
</form>
</body&g开发者_StackOverflowt;
</html>

and this is the php:

<html>
<?php
var $name = $_POST['name'];
var $age = $_POST['age'];
var $formname = $_POST['formname'];
if (!(empty($name))&&!(empty($age))&&!(empty($formname))) {
var $received = true;
}
else {
var $received = false;
}
?>
<head>
<title>Confirmation Page</title>
</head>
<body>
<p>Your input to the form: <?php echo $formname;?> was <?php if (!$received) {echo "not";}?>received.</p>
</body>
</html>


Get rid of 'var' in front of var $name = $_POST['name']; and the other variables. The var keyword was only used for classes (which your script is not).


Don't use the keyword var in that case. Just say:

$name = $_POST['name'];


You may want to read about variable on php.net.

There is a usage for that keyword. In php4 var was used to define class property. In php5 it's public/protected/private.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜