return to html

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • zoilus

    return to html

    Trying to write html form program that calls php prog. If php prog has
    problem with what was entered would like to return from php to html program.

    Is this possible and if so, how?

    TIA
  • Erwin Moller

    #2
    Re: return to html

    zoilus wrote:
    Trying to write html form program that calls php prog. If php prog has
    problem with what was entered would like to return from php to html
    program.
    >
    Is this possible and if so, how?
    >
    TIA
    Hi,

    Plain html pages are not refered to as programs, just html files.
    Unless the Javascript in them is worth calling a program. ;-)

    What you need is something like this:
    <?php
    // just an example, we expect a formelement named firstname
    // If not set, redirect to error.html
    if (!isset($_POST["firstname"])){
    // refuse
    header("Locatio n: http://www.example.com/error.html");
    exit;
    }

    // do your normal processing here.

    ?>


    Regards,
    Erwin Moller

    Comment

    • zoilus

      #3
      Re: return to html

      Erwin,

      Thanks for the post. Maybe you could help me with this code. The code is
      not transfering to variables to the search.php program.

      <html>
      <head>
      <title>testin g downloaded query form</title>
      </head>
      <body>


      <h2>Search</h2>
      <!-- <form name="search" method="post" action="<?=$PHP _SELF?>" -->
      <form name="search" method="post" action="search. php">
      Seach for: <input type="text" name="find" /in
      <Select NAME="field">
      <Option VALUE="fname">F irst Name</option>
      <Option VALUE="lname">L ast Name</option>
      <Option VALUE="info">Pr ofile</option>
      </Select>
      <input type="hidden" name="searching " value="yes" />
      <input type="submit" name="search" value="Search" />
      </form>

      </body>
      </html>

      none of the variable are set in search.php



      Erwin Moller wrote:
      zoilus wrote:
      >
      >
      >>Trying to write html form program that calls php prog. If php prog has
      >>problem with what was entered would like to return from php to html
      >>program.
      >>
      >>Is this possible and if so, how?
      >>
      >>TIA
      >
      >
      Hi,
      >
      Plain html pages are not refered to as programs, just html files.
      Unless the Javascript in them is worth calling a program. ;-)
      >
      What you need is something like this:
      <?php
      // just an example, we expect a formelement named firstname
      // If not set, redirect to error.html
      if (!isset($_POST["firstname"])){
      // refuse
      header("Locatio n: http://www.example.com/error.html");
      exit;
      }
      >
      // do your normal processing here.
      >
      ?>
      >
      >
      Regards,
      Erwin Moller

      Comment

      • =?ISO-8859-15?Q?Iv=E1n_S=E1nchez_Ortega?=

        #4
        Re: return to html

        zoilus wrote:
        none of the variable are set in search.php
        How are you accesing the variables there?

        --
        ----------------------------------
        Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

        http://acm.asoc.fi.upm.es/~mr/ ; http://acm.asoc.fi.upm.es/~ivan/
        MSN:i_eat_s_p_a _m_for_breakfas t@hotmail.com
        Jabber:ivansanc hez@jabber.org ; ivansanchez@kde talk.net

        Comment

        • zoilus

          #5
          Re: return to html

          print "You have entered search.php<br>" ;
          /*
          //This is only displayed if they have submitted the form
          print "<br>variab le fname, lname and info is: $fname, $lname, $info <br>";
          print "<br>variab le searching is: $searching";
          print "<br>variab le search is: $search";
          print "<br>variab le find is: $find";
          */
          // print_r(debug_b acktrace()); //got from web, does not seem to work.

          if (!isset($_POST["fname"])){
          print "fname is not set";
          }

          if ($searching =="yes")
          {
          echo "<h2>Result s</h2><p>";
          }

          //If they did not enter a search term we give them an error
          if ($find == "")
          {
          echo "<p>You forgot to enter a search term";
          exit;
          }


          Iván Sánchez Ortega wrote:
          zoilus wrote:
          >
          >
          >>none of the variable are set in search.php
          >
          >
          How are you accesing the variables there?
          >

          Comment

          • Erwin Moller

            #6
            Re: return to html

            zoilus wrote:
            print "You have entered search.php<br>" ;
            /*
            //This is only displayed if they have submitted the form
            print "<br>variab le fname, lname and info is: $fname, $lname, $info <br>";
            print "<br>variab le searching is: $searching";
            print "<br>variab le search is: $search";
            print "<br>variab le find is: $find";
            */
            // print_r(debug_b acktrace()); //got from web, does not seem to work.
            >
            if (!isset($_POST["fname"])){
            print "fname is not set";
            }
            >
            if ($searching =="yes")
            Stop here.

            I think you are relying on old (bad) PHP examples that use register_global s.
            $searching is empty in your example.

            Use: $_POST["searching"] instead.
            That contains the the value of the formelement named "searching" .
            (They are case sensitive.)

            Regards,
            Erwin Moller

            {
            echo "<h2>Result s</h2><p>";
            }
            >
            //If they did not enter a search term we give them an error
            if ($find == "")
            {
            echo "<p>You forgot to enter a search term";
            exit;
            }
            >
            >
            Iván Sánchez Ortega wrote:
            >
            >zoilus wrote:
            >>
            >>
            >>>none of the variable are set in search.php
            >>
            >>
            >How are you accesing the variables there?
            >>

            Comment

            • Geoff Berrow

              #7
              Re: return to html

              Message-ID: <EyA9i.60323$Sa 4.37790@bgtnsc0 5-news.ops.worldn et.att.net>
              from zoilus contained the following:
              >Trying to write html form program that calls php prog. If php prog has
              >problem with what was entered would like to return from php to html program.
              >
              >Is this possible and if so, how?
              The back button works.

              --
              Geoff Berrow (put thecat out to email)
              It's only Usenet, no one dies.
              My opinions, not the committee's, mine.
              Simple RFDs http://www.ckdog.co.uk/rfdmaker/

              Comment

              • Rik

                #8
                Re: return to html

                On Wed, 06 Jun 2007 19:23:45 +0200, Geoff Berrow <blthecat@ckdog .co.uk>
                wrote:
                Message-ID: <EyA9i.60323$Sa 4.37790@bgtnsc0 5-news.ops.worldn et.att.net>
                from zoilus contained the following:
                >
                >Trying to write html form program that calls php prog. If php prog has
                >problem with what was entered would like to return from php to html
                >program.
                >>
                >Is this possible and if so, how?
                >
                The back button works.
                But users aren't to be trusted to know that a back button exists :P
                --
                Rik Wasmus

                Comment

                • zoilus

                  #9
                  Re: return to html

                  My mistake. The copied program was severly lacking. Have made all
                  patches. Search program had no POST statements amoung other things.

                  Thanks to all



                  zoilus wrote:
                  print "You have entered search.php<br>" ;
                  /*
                  //This is only displayed if they have submitted the form
                  print "<br>variab le fname, lname and info is: $fname, $lname, $info <br>";
                  print "<br>variab le searching is: $searching";
                  print "<br>variab le search is: $search";
                  print "<br>variab le find is: $find";
                  */
                  // print_r(debug_b acktrace()); //got from web, does not seem to work.
                  >
                  if (!isset($_POST["fname"])){
                  print "fname is not set";
                  }
                  >
                  if ($searching =="yes")
                  {
                  echo "<h2>Result s</h2><p>";
                  }
                  >
                  //If they did not enter a search term we give them an error
                  if ($find == "")
                  {
                  echo "<p>You forgot to enter a search term";
                  exit;
                  }
                  >
                  >
                  Iván Sánchez Ortega wrote:
                  >
                  >zoilus wrote:
                  >>
                  >>
                  >>none of the variable are set in search.php
                  >>
                  >>
                  >>
                  >How are you accesing the variables there?
                  >>

                  Comment

                  Working...