Jump to content

Why doesn't this work?


Perad

Recommended Posts

I am making a form which has 3 steps.. Between each step the data is saved in sessions. The problem i have is that it transfers from page 1 to page 2. However when i submit page 2 it doesn't execute the page 2 code.

 

I have have stripped out all the form checks etc as these have nothing to do with the problem

 

URL - create.php?page=2

 

HTML

<form action="create.php" method="post">
//Entry Fields
<input type="submit" name="submit2" value="Submit" />
</form>

 

PHP

$page = $_GET['page'];
if ($page == 2) {
if (isset($_POST['submit2'])) {		
                if (empty($_POST['create_company'])) {
		$create_company = "empty";
		$formerror == TRUE;
	} else {
		$createpagetwo[] = MakeSafe($_POST['create_company']);
	}
	#Destroy Page 1 session, Create page 2 session

	if ($formerror == TRUE) {
		echo "Someting went wrong";
	} 
	else
	{ 
		session_register(page2);
		$_SESSION['createpageone'] = $createpageone;
		$_SESSION['createpagetwo'] = $createpagetwo;
		$_SESSION['namecolumns'] = $namecolumns;
		$_SESSION['namevalues'] = $namevalues;	
		echo '
			<script type="text/javascript">
				<!--
				window.location = "create.php?page=3;"
				//-->
			</script>';
	}
}	
// $smarty->assign Stuff
}

 

Code within -"if ($page == 2) {"- actually works... however the -"if (isset($_POST['submit2'])) {"- simply isn't being picked up.

 

Any ideas?

Link to comment
Share on other sites

Hi Pirad

You are saying that you can get value from $_GET but not from $_POST.

There is nothing wrong with the above code which you mention. But i think you can try with $_REQUEST as it takes both $_GET adn $_POST.

 

Moreover you can dump your register global variables status by phpinfo. as registar_global must be on to use above variables.

 

Thanks

Shaymol

 

Link to comment
Share on other sites

yes everything should work besides

 

echo '

<script type="text/javascript">

<!--

window.location = "create.php?page=3;"

//-->

</script>';

 

try it the other way round

 

echo "

<script type'text/javascript'>

<!--

window.location = 'create.php?page=3';

//-->

</script>";

 

Link to comment
Share on other sites

Ah, i found the problem, really my stupidity really and would rather not talk about it.

 

Could someone clear up what shaymol was saying about super globals?

 

I read an article on php.net but it just went straight over my head.

 

If its not too much trouble could someone highlight a superglobal that i am using and perhaps an alternative for it.

 

Thanks a lot.

 

Perad Out.

Link to comment
Share on other sites

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.