Question:
simple php code, but with a problem: can't receive data from variables. Need help.?
Willbor
2010-01-27 06:36:24 UTC
Hello. I have two files:
default.html and submitform.php, they are located in C:\wamp\www\Iza\
I set up WAMPserver. when I type http://localhost/Iza/default.html , it loads my default.html - everything looks OK!

My default.html has this source:




A1:
H1:








My submitform.php has this source.



print "Hi!";
print ("Thanks for submitting your name.");
print ($a1);
print (" ");
print ($h1);

?>




But, after I press a Submit button the result is (looks like php works, but the values of variables are not received):

Hi! Thanks for submitting your name.
Notice: Undefined variable: a1 in C:\wamp\www\Iza\submitform.php on line 6
Notice: Undefined variable: h1 in C:\wamp\www\Iza\submitform.php on line 8

Why I don't get values in a1 and h1?
Thank you.
Five answers:
J.J.'s Advice / Avis de J.J.
2010-01-27 06:46:20 UTC
You have a lot of bad syntax. Look carefully at the corrected version below.



default.html:

---------------------









A1:

H1:

















submitform.php:

------------------------








echo 'Hi!';

echo 'Thanks for submitting your name.' . "\r\n\r\n";

echo $_GET['a1'] . ' ' .$_GET['h1'];

?>



?
2016-12-11 01:25:21 UTC
M773a6e8cc2d647957be351ae07e5dk773a6e8cc2d647957be351ae07e5d sur773a6e8cc2d647957be351ae07e5d your for773a6e8cc2d647957be351ae07e5d h773a6e8cc2d647957be351ae07e5ds 773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d 773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5dthod of placed up. A773a6e8cc2d647957be351ae07e5dd th773a6e8cc2d647957be351ae07e5dt your fi773a6e8cc2d647957be351ae07e5dld h773a6e8cc2d647957be351ae07e5ds 'call' 773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d 773a6e8cc2d647957be351ae07e5dssig773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5dd to it, i773a6e8cc2d647957be351ae07e5d this c773a6e8cc2d647957be351ae07e5ds773a6e8cc2d647957be351ae07e5d: O773a6e8cc2d647957be351ae07e5dc773a6e8cc2d647957be351ae07e5d th773a6e8cc2d647957be351ae07e5d for773a6e8cc2d647957be351ae07e5d h773a6e8cc2d647957be351ae07e5ds b773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d sub773a6e8cc2d647957be351ae07e5ditt773a6e8cc2d647957be351ae07e5dd you c773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d s773a6e8cc2d647957be351ae07e5dv773a6e8cc2d647957be351ae07e5d th773a6e8cc2d647957be351ae07e5d v773a6e8cc2d647957be351ae07e5dlu773a6e8cc2d647957be351ae07e5d i773a6e8cc2d647957be351ae07e5d th773a6e8cc2d647957be351ae07e5d 773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d fi773a6e8cc2d647957be351ae07e5dld to 'call' v773a6e8cc2d647957be351ae07e5dri773a6e8cc2d647957be351ae07e5dbl773a6e8cc2d647957be351ae07e5d via usi773a6e8cc2d647957be351ae07e5dg th773a6e8cc2d647957be351ae07e5d followi773a6e8cc2d647957be351ae07e5dg own abode page cod773a6e8cc2d647957be351ae07e5d: $773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d = $_POST[773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d773a6e8cc2d647957be351ae07e5d];
anonymous
2010-01-27 06:58:15 UTC
Here you are using get method to send information.

The problem is that you did not accept the two variables in to php code..

You are using GET here , so you should have some lines like :

$a1=$_GET["a1"];

$h1=$_GET["h1"];



before print($a1)



Also , when doing coding for websites, you should be stripping of unwanted characters so that

no one will be able to exploit it. Since this is fairly simple one, no need to do this here..



If you want to learn more on php, go to w3schools.com or phpf1.com
dango
2010-01-27 06:44:59 UTC
Remove A1: and H1: and try reloading the page.

Should use the $_GET['a1'] to retrieve the value.
?
2010-01-27 06:42:13 UTC
you are not storing anything into those variables. you are storing values into the test boxes.



add this



$a1 = $_GET['a1'];

$h1 = $_GET['ha'];



place that before you print them.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...