erikla Posted May 4, 2014 Share Posted May 4, 2014 Dear phpfreak users It is several years ago I looked at php code, so I am very rusty here. Many years ago I managed (with some help) to produce a guestbook for my website. It is the only part containing php code. A week ago I changed webhotel and after transferring my website to the new Webhotel, something is not working properly. I have been trying to pinpoint what it is. I think I have found one issue: When a user fill out a form and press the submit button, the variables are not transferred to the php page, which is written in the action part of the form. To make it less confusing I have deleted parts of my php page and just kept the part, where I guess there is a problem. The form page named guest_form.html: <HTML><HEAD><TITLE>Add items to the Guest book</TITLE><LINK REL=stylesheet TYPE="text/css" HREF="generel/hoved.css"></HEAD><BODY><h1><font color="#903C39">Guestbook</font></h1><FORM method="POST" action="guest_save.php"> <hr><br><table cellspacing=5 cellpadding=5><tr><td valign=top><strong><p><b><font color="#903C39">Name</font></b></p></strong></td><td valign=top><INPUT type="text" name="navn" size=40 maxlength=60></td></tr><tr><td valign=top><strong><p><b><font color="#903C39">E-mail</font></b></p></strong></td><td valign=top><INPUT type="text" name="epost" size=40 maxlength=60></td></tr><tr><td valign=top><strong><p><b><font color="#903C39">Contribution</font></b></p></strong></td><td valign=top><TEXTAREA name="indlaeg" cols=50 rows=6></TEXTAREA></td></tr><tr><td align=center colspan=2><INPUT type="submit" value="Submit Contribution"></td></tr></table></FORM></BODY></HTML> The guest_save.php page: <?phpif ($navn == "") {echo "Name is empty";}if ($navn != "") {echo "Name is not empty";} ?> Comments: I uploaded both pages and they are located at the same level. Then I filled out the form and pressed the submit button. The php page was displayed with the text: "Name is empty". So it look like the content of 'navn' is not tranferred to the php page. Is my code wrong could it be a problem at the Webhotel? I really hope somebody can push me in the right direction ... Regards, Erik Quote Link to comment https://forums.phpfreaks.com/topic/288224-guestbook-problem/ Share on other sites More sharing options...
Solution trq Posted May 4, 2014 Solution Share Posted May 4, 2014 Your code is severely out of date, relying on register globals being switched on, it has been off by default (for security reasons) for a long time (probably 8+ years). You will now need to use `$_POST['navn]` instead of plain old `$navn` in your code. Quote Link to comment https://forums.phpfreaks.com/topic/288224-guestbook-problem/#findComment-1478124 Share on other sites More sharing options...
erikla Posted May 4, 2014 Author Share Posted May 4, 2014 Thanks a lot! I understand that I have been using deprecated code and the new Webhotel did not support the old way ... I just changed it the way you describe and now it Works as expected! Great! Erik Quote Link to comment https://forums.phpfreaks.com/topic/288224-guestbook-problem/#findComment-1478127 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.