PHP $_GET not giving me required result -
i writing php code in adobe dreamweaver. code shown below. expecting code output 2 boxes, write something. , when click on submit button, expect see 2 separate things entered box concatenated. i'm not getting concatenation. in fact, nothing happens when click on submit. confused. code not should using dreamweaver for? relatively new php , not understand bits. suspicion dreamweaver not recognize "twofieldform.php". can please tell me how can overcome issue?
<!doctype html> <html> <head> </head> <body> <h1>form filler</h1> <?php function joined($s1, $s2) { return array($s1.$s2, strlen($s1.$s2)); } $first = $_get[fieldone]; $second = $_get[fieldtwo]; $answer = joined($first, $second); echo "the concatenated string \"{$answer[0]}\" , length \"{$answer[1]}\"; ?> <form action = "twofieldform.php" method = "get"> field 1 : <input type = "text" name = "fieldone"/> field 2 : <input type = "text" name = "fieldtwo"/> <input type = "submit"> </form> </body> </html>
<!doctype html> <html> <head> </head> <body> <h1>form filler</h1> <?php function joined($s1, $s2) { return array($s1.$s2, strlen($s1.$s2)); } $first = $_get['fieldone']; $second = $_get['fieldtwo']; $answer = joined($first, $second); echo "the concatenated string \"{$answer[0]}\" , length \"{$answer[1]}\""; ?> <form action="" method="get"> field 1 : <input type="text" name="fieldone"/> field 2 : <input type="text" name="fieldtwo"/> <input type="submit"> </form> </body> </html>
explanation: have add quotes in $_get['']. remember indention please, when see people using adobe dreamweaver, code horrible... if refering same file, don't have use action="somewhat.php". leave empty. aswell have missed " after echo statement. work now. please start using ide won't have basic mistakes because ide show mistakes already...
Comments
Post a Comment