Posting to a URL

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

    Posting to a URL

    Sorry but I have a beginners question.

    (see www.freeweekends.co.uk/formask.php)

    I have a form that checks for a unique id $townref of a given town

    If this unique id is entered and found, I then want the associated
    variables $townname and $towntitlepic passed to the url


    Have passed variables to a different URL within a form submit, but how
    do I do this within a normal condition statement??

    Code ---------------------------

    <?php $townref = $_GET['town']; echo $townref; ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
    <p align="center"> &nbsp;
    <p align="center"> &nbsp;<font color="#FF0000" >town id</font><input
    type="text" name="town" size="20" value="" />&nbsp;
    <input type="submit" value="GO" />
    </p>
    </form>
    <?php
    $resulttown = @mysql_query ("SELECT townname, townref, towntitlepic
    FROM townid_uks49179 WHERE townref='$townr ef'");
    while ($row = mysql_fetch_arr ay($resulttown) )
    {
    $townname = $row['townname'];
    $townref = $row['townref'];
    $towntitlepic = $row['towntitlepic'];
    }
    ?>

    <?php if (isset($GET['resulttown'])) ????????? URL formreply.php and
    variables ???????


    Many thanks

    Alec

  • Colin McKinnon

    #2
    Re: Posting to a URL

    Alec wrote:
    Sorry but I have a beginners question.
    >
    (see www.freeweekends.co.uk/formask.php)
    >
    I have a form that checks for a unique id $townref of a given town
    >
    If this unique id is entered and found, I then want the associated
    variables $townname and $towntitlepic passed to the url

    >
    $townname='hell o';
    $dest="http://www.freeweekend s.co.uk/formreply.php?t ownname={$townn ame}&pic={$town titlepic}";
    $gen_output=fil e($dest);

    (but you might want to pass the parameters thru htmlentites first).

    If you really want to POST instead of GET - see the curl functions in the
    manual.

    C.

    Comment

    • Krustov

      #3
      Re: Posting to a URL

      <comp.lang.ph p>
      <Alec>
      <3 Jul 2006 12:48:19 -0700>
      <1151956099.286 710.125580@p79g 2000cwp.googleg roups.com>
      <?php $townref = $_GET['town']; echo $townref; ?>
      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
      <p align="center"> &nbsp;
      <p align="center"> &nbsp;<font color="#FF0000" >town id</font><input
      type="text" name="town" size="20" value="" />&nbsp;
      <input type="submit" value="GO" />
      </p>
      </form>
      <?php
      $resulttown = @mysql_query ("SELECT townname, townref, towntitlepic
      FROM townid_uks49179 WHERE townref='$townr ef'");
      while ($row = mysql_fetch_arr ay($resulttown) )
      {
      $townname = $row['townname'];
      $townref = $row['townref'];
      $towntitlepic = $row['towntitlepic'];
      }
      ?>
      >
      Not sure if i understand your question correctly (even though i know it
      makes perfect sense to you) and apart from that this probably isnt the
      best way to do it anyway .

      <?php
      $resulttown = @mysql_query ("SELECT townname, townref, towntitlepic
      FROM townid_uks49179 WHERE townref='$townr ef'");
      while ($row = mysql_fetch_arr ay($resulttown) )
      {
      $townname = $row['townname'];
      $townref = $row['townref'];
      $towntitlepic = $row['towntitlepic'];
      }
      ?>

      <?php $townref = $_GET['town']; echo $townref; ?>
      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
      <p align="center"> &nbsp;
      <p align="center"> &nbsp;<font color="#FF0000" >town id</font>
      <input type="text" name="town" size="20" value="" />&nbsp;
      <?php
      if ($townname<>"") {print "<input type=text name=townname size=20 value=
      $townname />";}
      if ($townref<>"") {print "<input type=text name=townref size=20 value=
      $townname />";}
      if ($townpic<>"") {print "<input type=text name=townpic size=20 value=
      $townpic />";}
      ?>
      <input type="submit" value="GO" />
      </p>
      </form>


      --
      Encrypted email address

      Comment

      • Alec

        #4
        Re: Posting to a URL

        Krustov

        Thanks for the reply, will try to better explain.

        Step 1

        In my database I have a list of towns each with fields for 'townname',
        'townref' and 'towntitlepic'.

        I have a form where the user enters a unique 'townref' number and
        submits the form. The code below checks to see if this unique 'townref'
        number can be found in the database, and when so then extracts the
        related fields 'townname' and 'towntitlepic'.

        ---------------

        <?php $townref = $_GET['town']; echo $townref; ?>
        <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
        <p align="center"> &nbsp;
        <p align="center"> &nbsp;<font color="#FF0000" >town id</font><input
        type="text" name="town" size="20" value="" />&nbsp;
        <input type="submit" value="GO" />
        </p>
        </form>
        <?php
        $resulttown = @mysql_query ("SELECT townname, townref, towntitlepic
        FROM townid_uks49179 WHERE townref='$townr ef'");
        while ($row = mysql_fetch_arr ay($resulttown) )
        {
        $townname = $row['townname'];
        $townref = $row['townref'];
        $towntitlepic = $row['towntitlepic'];
        }
        ?>

        -------------------

        Step 2 - The search works OK and returns the correct 'townname' and
        'towntitlepic' that relate to the entered 'townref' value in the form
        (its really just a check to see if the town ref entered actually
        exists)

        I want to then have a condition, so if the 'townref' does exist, this
        and the related 'townname' and 'towntitlepic' variables are passed to a
        second page called www.freeweekends.co.uk/formanswer.php. The user has
        already clicked on the form submit to do the check, so how do I pass
        the variables to the new page?

        Sorry because I know the answer will be really simply.

        Alec

        Comment

        • Krustov

          #5
          Re: Posting to a URL

          <comp.lang.ph p>
          <Alec>
          <5 Jul 2006 14:07:48 -0700>
          <1152133668.137 407.66360@b68g2 000cwa.googlegr oups.com>
          <?php $townref = $_GET['town']; echo $townref; ?>
          <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
          >
          Step 2 - The search works OK and returns the correct 'townname' and
          'towntitlepic' that relate to the entered 'townref' value in the form
          (its really just a check to see if the town ref entered actually
          exists)
          >
          I want to then have a condition, so if the 'townref' does exist, this
          and the related 'townname' and 'towntitlepic' variables are passed to a
          second page called www.freeweekends.co.uk/formanswer.php. The user has
          already clicked on the form submit to do the check, so how do I pass
          the variables to the new page?
          >
          Sorry because I know the answer will be really simply.
          >
          <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">

          Havent tried the above - but doesnt clicking on submit take you to the
          same webpage ? .


          On the first page .....

          <form action="formans wer.php" method="get">
          <input type="text" name="towndemo" size="30">
          <input type="text" name="junk" size="30">
          <input type="submit" name="Submit" value="S U B M I T">
          </form>

          On the second page .....

          <?php
          $grab=$_POST['towndemo'];
          $junk=$_POST['junk'];
          (check town name against database)
          (display results - if any)
          ?>

          $grab will have/contain whatever text you typed into the form

          $junk will have/contain whatever text you typed into the form


          To sum up , Its better if you check and display on the second page .


          --
          Encrypted email address

          Comment

          Working...