Jump to content

Guestbook problem


erikla
Go to solution Solved by trq,

Recommended Posts

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:

 

<?php

if ($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

 

Link to comment
Share on other sites

  • Solution

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.