Jump to content

[SOLVED] 2x !isset($_POST['submit']) - how to get it to work?


Lokolo

Recommended Posts

ok basically i have 2 forms, one shows up at the start, that gets submitted and the page refreshes wth the 2nd one.

 

however, i cannot figure how to submit the 2nd one as the forms are both submit forms.

 

(basically once i submit the first one, it then goes to the elses of both. i can get the 2nd form to display if i change the 2nd !isset($_POST['submit']) to something else but then i can't submit that one)

 

        <?
if (!isset($_POST['submit'])) {
	?>
	<h2>
	<form action="<?php echo $_SERVER['PHP_SELF']; ?>" 
		method="post" 
			onsubmit="return checkSubmit(this);">
		Number of Rooms: <input type="text" size="3" multiple style="height: 20px" maxlength="2" name="numrooms">
		<input type="submit" name="submit" value="Upgrade">
	</form>
	</h2>
	<?
} else {
	upgradehotel($_POST['numrooms']);
	if (!isset($_POST['submit'])) {
	?>
	<form action="<?php echo $_SERVER['PHP_SELF']; ?>"
				method="post" 
				onsubmit="return checkSubmit(this);">
		<input type="submit" name="confirm" value="Yes">
		<input type="submit" name="confirm" value="No">
	</form></h2>
	<? 
	} ELSE {
	echo "work damnit work";
	}
	?>

 

heh thanks!

        <?
if (!isset($_POST['submit'])) {
	?>
	<h2>
	<form action="<?php echo $_SERVER['PHP_SELF']; ?>" 
		method="post" 
			onsubmit="return checkSubmit(this);">
		Number of Rooms: <input type="text" size="3" multiple style="height: 20px" maxlength="2" name="numrooms">
		<input type="submit" name="submit" value="Upgrade">
	</form>
	</h2>
	<?
} else {
	upgradehotel($_POST['numrooms']);
	if (!isset($_POST['confirm'])) {
	?>
	<form action="<?php echo $_SERVER['PHP_SELF']; ?>"
				method="post" 
				onsubmit="return checkSubmit(this);">
		<input type="submit" name="confirm" value="Yes">
		<input type="submit" name="confirm" value="No">
	</form></h2>
	<? 
	} ELSE {
	echo "work damnit work";
	}
	?>

 

Your logic is flawed. For the second portion you need to check $_POST['confirm'] as that is what you gave the name of the submit field.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.