Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Newbie, simple page with form

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Newbie, simple page with form

Postby andornot » Fri Nov 15, 2013 6:25 am

Hello!
I've just started to learn PHP and I'm trying to understand something more.
I made some exercise/test to learn how to use var, array and so on, but I'm missing something about the basics..
For example I should do this:

Implement  a  class  RequestFormView  in  the  file  RequestFormView.php  with  a  method to displays  a simple HTML  form containing  the  following  fields:

Name:   [input  type  text,  string]
Email:   [input  type  text,  string  email]

The  form  data  should  be  transmitted  via  HTTP  POST.

[1] Create  a  small  test  page  index.php  that  renders  the  form  when  accessed  without  any  GET  or  POST  parameters.
When  the  request  contains  the  GET  Parameter  ?submit=1  a  simple  list  of  key  value  pairs  of  the  transmitted  data
should  be  printed  instead  of  the  form.

Modify  your  RequestFormView  in  order  to  render  all  submitted  data  within  the  form.   Create  a  new  test  page
1_2index.php  based  on  1index.php  that  displays  the  form  view  after  submission.  The  default  values  of  the  form
elements  should  now  be  the  ones  that  were  submitted.


but I can't understand exactly what I should do.

Until now I make my index.php and the class to show the form (code is below) and it should working quite good.
What's the point: I don't know how to continue. [1] what does it means? I browse to index.php, it show me the form, and then? What does "request contains the GET Parameter ?submit=1" means?

I'm NOT searching for someone that write code for me, but I would an help to understand what it's asking me..

This is what I've done until now

Code: Select all
<!DOCTYPE unspecified PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
   <?php
      echo "<title>" . " First page with PDT" . "</title>";
   ?>
</head>

<body>
   <?php
      require_once('RequestFormView.php');
      $form = new RequestFormView();
      
      $form->show();
      
   ?>
</body>

</html>


Code: Select all
<?php
   class RequestFormView {
      var $name;
      var $email;
      
      function setName() {
         $name = $_GET.name;
      }
      
      function setEmail() {
         $email = $_GET.email;
      }
            
      function show() {
         echo <<<END
            <form method="POST" action="RequestFormview.php">
               <table border="1" align="center" width="20%">
               <tr>
                  <td>Name</td>
                  <td><input name="name"></td>
               </tr>
               <tr>
                  <td>Email</td>
                  <td><input name="email"></td>
               </tr>
               <tr>
                  <input type=submit>
               </tr>
               </table>
            </form>
END;
      }
   }
?>


Can anyone show me which is the way?

Thanks!!
andornot
New php-forum User
New php-forum User
 
Posts: 1
Joined: Fri Nov 15, 2013 6:05 am

Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron