form shortcut

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jonborbon
    New Member
    • Sep 2006
    • 5

    #1

    form shortcut

    Dear all,

    I have a display of records from a table, alongside each record is an image for deleting, updating, etc. in a page named DISPLAY.Php.

    What I want to dos is instead of displaying a form to delete a record specified by the delname textbox (as shown below)
    Code:
    <form action="process.php" method="POST">
      <input type="text" name="delname">
            :  other entries
      <input type="hidden" name="fdeluser" value="1">
      <input type="submit" value "Delete this user">
    </form>
    I would just assign use the image for deleting the record duplicating the form function above using these:
    Code:
     
    <a href="process.php?action=fdeluser&amp;deluser=' . $uname .'"><image source></a>
    Problem is, process.php does not delete the record specified by $uname. Any help is highly appreciated.
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    If we assume that the statement you showed
    [HTML]<a href="process.p hp?action=fdelu ser&amp;deluser =' . $uname .'"><image source></a>[/HTML]
    is actually what is coded, i.e. in html without using php to echo, then you must let the $uname be echoed by php as in:
    [HTML]<a href="process.p hp?action=fdelu ser&amp;deluser =<?php echo $uname ?>"><image source></a>[/HTML]
    If it has to be coded using php (i.e. using echo), then this statement should be
    [PHP]echo '<a href="process.p hp?action=fdelu ser&amp;deluser =' . $uname .'"><image source></a>';[/PHP]

    Ronald :cool:

    Comment

    • jonborbon
      New Member
      • Sep 2006
      • 5

      #3
      Ronald,

      Thanks for the post. I've tried what you've suggested. Unfortunately, when I try to catch the arguments passed using isset($_GET[]) in a different form, it returns 1 for all the arguments.

      The problem I have could be easily remedied if it is in the form. Is there a way to pass values to other php page without using a form?

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        There must have been some typing error or what. The following code snippets show what I meant.
        A.PHP shows the link to B.PHP.
        B.PHP show what is inside the $_GET array when loaded. Run them and see.
        [PHP]
        A.PHP
        ------
        <?php
        $uname = "Johnny";
        ?>
        <a href='b.php?act ion=fdeluser&de luser=<?php echo $uname ?>'><image source></a>

        B.PHP
        -----
        <?php
        echo '<pre>'; print_r($_GET);
        if (isset($_GET['action']))
        echo "action=".$ _GET['action'];
        else
        echo 'no action parameter in GET string';
        if (isset($_GET['deluser']))
        echo "deluser=".$_GE T['deluser'];
        else
        echo 'no deluser parameter in GET string';
        ?>
        [/PHP]

        Ronald :cool:

        Comment

        Working...