Simple PHP Help...
RWB
Icrontian
OK, I have been trying to relearn PHP, I haven't ever spent much time with it so I have forgotten it since I last tinkered with it. I am using easyphp 1.7, from easyphp.org, I got it all up and working.
So I am starting anew, I am trying to work my way through my book of tutorials, and for some reason this one tutorial isn't working properly. Why??? Yes, I typed what is in the book exactly, I figure it is some kind of code variation between new and old version of PHP? I'm running 4.3.3 I believe of PHP.
Anyways the problem is that in neither case, POST nor GET I don't get the results back. I am supposed to get a "Welcome, User!" show up on the same page after submitting the characters name.
Using GET
[PHP]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Example Form Processing</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body bgcolor="ffffff">
<form name="frmSample" action="exampleformproc_get.php" method="get">
<b>What is your character's name?</b><br>
<input type="text" name="strCharacter">
<input type="submit" value="Submit">
</form>
<?php
if(isset($strCharcter))
{
echo("Welcome, " . $_REQUEST["strCharacter"] . "!");
}
?>
</body>
</html>
[/PHP]
Using POST
[PHP]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Example Form Processing</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body bgcolor="ffffff">
<form name="frmSample" action="exampleformproc_post.php" method="post">
<b>What is your character's name?</b><br>
<input type="text" name="strCharacter">
<input type="submit" value="Submit">
</form>
<?php
if(isset($_POST["strCharcter"]))
{
echo("Welcome, " . $_POST["strCharacter"] . "!");
}
?>
</body>
</html>
[/PHP]
BTW, when I use GET my address bar does in fact change. When using GET and place "Chris" in the form I recieve the following as my new address after submitting:
"http://localhost/php Game Programming/exampleformproc_get.php?strCharacter=Chris"
When using POST nothing changes.
So I am starting anew, I am trying to work my way through my book of tutorials, and for some reason this one tutorial isn't working properly. Why??? Yes, I typed what is in the book exactly, I figure it is some kind of code variation between new and old version of PHP? I'm running 4.3.3 I believe of PHP.
Anyways the problem is that in neither case, POST nor GET I don't get the results back. I am supposed to get a "Welcome, User!" show up on the same page after submitting the characters name.
Using GET
[PHP]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Example Form Processing</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body bgcolor="ffffff">
<form name="frmSample" action="exampleformproc_get.php" method="get">
<b>What is your character's name?</b><br>
<input type="text" name="strCharacter">
<input type="submit" value="Submit">
</form>
<?php
if(isset($strCharcter))
{
echo("Welcome, " . $_REQUEST["strCharacter"] . "!");
}
?>
</body>
</html>
[/PHP]
Using POST
[PHP]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Example Form Processing</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body bgcolor="ffffff">
<form name="frmSample" action="exampleformproc_post.php" method="post">
<b>What is your character's name?</b><br>
<input type="text" name="strCharacter">
<input type="submit" value="Submit">
</form>
<?php
if(isset($_POST["strCharcter"]))
{
echo("Welcome, " . $_POST["strCharacter"] . "!");
}
?>
</body>
</html>
[/PHP]
BTW, when I use GET my address bar does in fact change. When using GET and place "Chris" in the form I recieve the following as my new address after submitting:
"http://localhost/php Game Programming/exampleformproc_get.php?strCharacter=Chris"
When using POST nothing changes.
0
Comments
if(isset($_POST["strCharcter"]))
should be..
if(isset($_POST["strCharacter"]))
If there is a value for strCharacter it should show up with something, but I guess for some reason it's not finding a value for it?
if(isset($strCharcter))
To:
if(isset($_GET))
if(isset($_REQUEST))
to no avail, amoungst other minor tweaks that didn't work either.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Example Form Processing</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body bgcolor="ffffff">
<form name="frmSample" action="exampleformproc_get.php" method="get">
<b>What is your character's name?</b>
<input type="text" name="test">
<input type="submit" value="Submit">
</form>
<?php
if(isset($_GET))
{
echo 'Welcome, '.$_GET.'!';
}
?>
</body>
</html>
[/php]
if(isset($_GET))
{
echo("Welcome, " . $_REQUEST . "!");
}
I had:
if(isset($_GET))
{
echo("Welcome, " . $_REQUEST . "!");
}
I need a better eye for these very minor issues....