Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.