How to put a if-else statement around a submit click

I’m having two problems which are the same between three php files. All 3 are php inside xhtml pages.

I need to make the code so that when that if the submit button in file1 is pushed, it goes to file2, but if its not pushed, then it displays an error_message and provides a link to file 1.

Accordingly, for file2, when the submit button is pushed, i need it to go to file3, but if its not pushed, then i need it to display an error_msg and provide a link to file1. Any help as I can’t figure this one part out.

file 1:

[CODE]

<div id="content">

<?php if (!empty($error_message)) { ?>
<p><?php echo $error_message; ?></p>
<?php } ?>

	<form action="Auth_CityForm.php" id="loginForm" method="post">


		<div id="loginData">
	
    		<label>User ID: </label>
			<input type="text" name="user"/>
			<br \>
	        <label>Password:</label>
			<input type="password" name="password" /> <br \>
		</div>

	    <div id="buttons">
			<label>&nbsp;</label>
			<!-- This is the submit button for submission of credentials -->
	        <input id="submit" type="submit" value="SubmitCredentials" class="submit_btn"/>

		</div>


	</form>
</div>
[/CODE]

file2:

[HTML]

<?php if ($user == "test" && $password == "test") { echo "Hello ".$user; ?>
    <br />
    <form name="city_name" action="CityTemperatureResp.php" method = "post">
		<input type="text" name="city" /><br />
        <input type="submit" value="SubmitCityName"/>
    </form>
	
	
} [/HTML]

file3:

[HTML]<?php
// $city=$_POST[‘city’];
$city=$_POST[‘city’];
?>

City temperature response <?php echo "In ".$city." the temperature is 22 C.
"; print "Login"; ?> [/HTML]
Sponsor our Newsletter | Privacy Policy | Terms of Service