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
https://forums.phpfreaks.com/topic/47533-why-doesnt-this-work/
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
https://forums.phpfreaks.com/topic/47533-why-doesnt-this-work/#findComment-232020
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
https://forums.phpfreaks.com/topic/47533-why-doesnt-this-work/#findComment-232026
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
https://forums.phpfreaks.com/topic/47533-why-doesnt-this-work/#findComment-232038
Share on other sites

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.