Jump to content

Simple HTML submit form using PHP not working


shilpa

Recommended Posts

Hi,

I am learning PHP now, so pardon my silly question which I am not able to resolve from a week. I have created a simple web form where in I display the values entered by a user.

 

 

<form action ="reply.php" id="myForm" method="post" >

      Name: <input type="text" name="name" size="25" maxlength="50" /> <br> </br>

      Description: <textarea name="editor1"> </textarea>

      <input type="submit" value="Submit"  />

</form>

 

and reply.php contains:

<?php

    echo "In reply page";

 

    foreach($_POST as $field => $value)

  {

        echo "$field = $value";

  }

?>

 

When I click on the submit button, I just get a blank page without any values from the form. Can anyone please let me know what am I missing?

 

Set up:

I am using Netbeans with PHP bundle added on to it. When i run only a simple php proj it displays that page in localhost/nameofproj, but when I run a php file along with a jsp file, it runs in localhost:8080/nameofproj.  Is this the reason(localhost:8080 instead of just localhost ) for showing a blank page, not even a simple echo stmt, when i click on submit?

I even re installed netbeans, still no luck.

 

Thanks in advance.

Try putting some id's in the form..

 

<form action ="reply.php" id="myForm" method="post" >
      Name: <input type="text" name="name" id="name" size="25" maxlength="50" /> <br> </br>
      Description: <textarea name="editor1" id="editor1"> </textarea>
      <input type="submit" value="Submit"  />
</form>

I did put id to forms and try. Forms are coming fine. Problem is only after i click on submit  button in the form. After i click on submit it shows a blank page.

The url after submit brings me to http://localhost:8080/sampleproj/reply.php, thats correct as in forms action i have given it as reply.php

If i put the php page alone as a separate proj, it works fine. the url then is http://localhost/reply.php

 

I installed netbeans again but still no luck, I am not understanding what am i doing wrong.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.