Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form validation producing an error

Status
Not open for further replies.

lauraSatellite

Technical User
Jul 22, 2004
35
IE
hi,
i have the following page:

Code:
[i]
<?php
session_start();
header("Cache-control: private"); // IE 6 Fix.
?>
<html>
<head>
<title>Page 1</title>
</head>
<body>
<p>Please select one of the following:</P>
Options:
<br><br>
<form method="POST" action="page2.php">
<input type=radio name=option value=1>Text file<BR>
<input type=radio name=option value=2>HTML file<BR>
<input type=radio name=option value=3>Excel file<BR>
<input type=radio name=option value=4>Word file<BR>
<button type="submit">Continue</button>
</form>
</body>
</html>
[/i]

On the next page, page2.php i have:

[i]
<?php
session_start();
header("Cache-control: private"); // IE 6 Fix.
?>
<html>
<head>
<title>Page 2</title>
</head>
<?php
  if(!(isset($_POST['option'])))
  {   	print "You must make a selection!";
?>		
        <P>
        <body>
  	<button type="back"onclick="history.back()">Back</button></P>
<?php
  }
  else
  {    <body>
       //some code for the body
  }
</body>
</html>
[/i]

When i select a radio-button, all goes well.
If i dont select one, "You must make a selection!" along with the back button is displayed. When i click the back button i return to page1.php, but the "page loaded with errors" symbol is present. When i click this it tells me i have an error:
line 7,
Char 14,
Expected ';'
on page1.php
This corresponds to a location between the <title> tags which makes no sence to me.

Any ideas on this would be appreciated.
Thanks.
 
This is due to your JAVASCRIPT.
It's not really a PHP issue.

You forgot the <script></script>

Also, dont echo outside of the <body></body>, as that is what is to contain your content.

I also dont understand why you need the body like you do, as you can add the <body> opening tag, where you have the </head>.

Also:
if(!(isset($_POST['option'])))
=>
if(!isset($_POST['option']))

Also keep your <p></p> in lowercase, not UPPERCASE.

Good luck!


Olav Alexander Mjelde
Admin & Webmaster
 
thanks a million for your helpful comments on the code.
its working now :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top