tags:

views:

52

answers:

3

Here's my code, what I want to do is to be able to have a back button in the script, so that the user will not be clicking on the back button on the web browser everytime he forgets to input something that is mandatory: But I get the parse error again,what should be the correct one?

   if(!isset($_POST['fname'])||trim($_POST['fname'])==""){die("Error:Enter Firstname!");     echo "<input type="button" value="Back" onClick="history.go(-1);return true;">"

}
+1  A: 
if(!isset($_POST['fname']) || trim($_POST['fname']) == "") {
  echo "Error:Enter Firstname!";     
  echo '<input type="button" value="Back" onClick="history.go(-1);return true;">';
  die();
}
Frank Farmer
A: 

You have to escape your quotes for one thing --

echo "<input type=\"button\" value=\"Back\" onClick=\"history.go(-1);return true;\">"

(or use single quotes as above)

Devin Ceartas
+1  A: 

You can't include double quotes inside a double quoted string without escaping them:

echo "<input type=\"button\" value=\"Back\" onClick=\"history.go(-1);return true;\">"

Or since you have no variable to parse:

echo '<input type="button" value="Back" onClick="history.go(-1);return true;">'
Erik