0

i am new to php and i'm facing the following error in most of the codes. instead of output, parse error ( ! ) Parse error: syntax error, unexpected '=' on line 12 is shown. this error is shown in every code.

<html>
<head>
<title>Check For Blank Text Boxes</title>
</head>
<body>
<?php 
$first ="";
$second = "";

function display_error_message($user_text) {

if ($user_text = = "") {
print "One or more blank text boxes detected";
} 
else {
print "Text boxes OK";
}
}

if ($_SERVER['REQUEST_METHOD'] = = 'POST'){

$first = trim($_POST['first']);
$second = trim($_POST['second']);

display_error_message($first);
display_error_message($second);
}

?>
</body>

<FORM Method = "POST" action ="formFunction.php">

First Name: <INPUT TYPE = "text" name = "first" value ="<?=$first?>">
Surnmae: <INPUT TYPE = "text" name = "second" value ="<?=$second?>">

<input type="submit" name="Submit" value="Submit">
</FORM>
</html>

2 Answers2

1

try with this,

if ($user_text == "") { 

}

Problem is space between '=' signs

Thili77
  • 1,061
  • 12
  • 20
0

To compare value in php used == not = =.

Onkar
  • 2,409
  • 2
  • 11
  • 14