View Single Post
Math Is Hard
#1
May24-07, 12:05 AM
Emeritus
Sci Advisor
PF Gold
Math Is Hard's Avatar
P: 4,922
Howdy, tonight I was playing around with trying to pass a value from a form field and use it for an "if" statement in php.
the html:
<HTML>
<HEAD>
<TITLE>Form Test</TITLE>
</HEAD>
<BODY>
<H1>Form Test</H1>

<form name="input" action="myscript.php" method="get">
Enter a 1 or a 2:
<input type="text" name="page_number_from_form">

<input type="submit" value="Submit">

</form>
</BODY>
</HTML>
myscript.php:
#!/usr/local/bin/php
<?php 
$page_number="";

if(isset($_GET["page_number_from_form"])) $page_number = $_GET["page_number_from_form"];

if($page_number="1")
{
	
	echo 'Number One.';

}
else if($page_number="2")
{

	echo 'Number Two.';
	
}
else
	echo 'No page number.';
?>
No matter what I type in (or don't type in) it always echos "Number One". Is there a way to pass an integer from the form field instead of text? Maybe a way to convert it?
Thanks!
Phys.Org News Partner Science news on Phys.org
Physical constant is constant even in strong gravitational fields
Montreal VR headset team turns to crowdfunding for Totem
Researchers study vital 'on/off switches' that control when bacteria turn deadly