PHP will not post to next form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • micksitup
    New Member
    • Feb 2007
    • 32

    PHP will not post to next form

    hi all.

    I have 3 files:-

    Pick_moduser.ph p
    do_moduser.php
    show_moduser.ph p

    problem is it just doesnt want to pass anything through

    can anybody please advise as to whats up with it!

    here is the code

    pick_moduser.ph p
    [code=php]
    <?php
    include("connec tion.inc.php");
    $connection = connect();

    $sql = "SELECT email, username, password
    FROM tblAdmin
    ORDER BY email";

    $result = @mysql_query($s ql) or
    die("Couldn't execute query.");

    $option_block = "";

    while ($row = mysql_fetch_arr ay($result))
    {
    $email = $row['email'];
    $username = $row['username'];
    $password = $row['password'];

    $option_block .= "<option value=\"$userna me\">$username , $email, $password</option>";
    }
    $display_block = "

    <form method=\"post\" action=\"show_m oduser.php\">

    <p><strong>cont act:</strong>
    <select name=\"username \">
    $option_block
    </select>

    <input type=\"submit\" name=\"submit\"
    value=\"select this user\"></p>
    </form>
    ";

    ?>
    <h3>Modify a User</h3>
    <P>Select a user from the list below, to modify the user's record.</p>

    <?php echo "$display_block "; ?>
    [/code]

    show_moduser.ph p

    [code=php]
    <form method="post" action="do_modu ser.php">
    <input type="hidden" name="username"
    value="<?php echo "$username";?>" >
    <table cellspacing=3 cellpadding=5 width="532">
    <tr>
    <td valign=top>
    <p><strong>emai l:</strong><br>
    <input type="text" name="email" value="<? echo "$email";?> " size=35 maxlength=75></p>

    <p><strong>user name:</strong><br>
    <input type="text" name="username"
    value="<? echo "$username" ;?>" size=35 maxlength=75></p>

    <p><strong>pass word:</strong><br>
    <input type="text" name="password"
    value="<? echo "$password" ;?>" size=35 maxlength=75></p>
    </td>
    </tr>
    <tr>
    <td align=center width="516"><p> <input type="submit" name="submit" value="update user information"></p>
    </td>
    </tr>
    </table>
    </form>


    Do_moduser.php

    <?php
    include("connec tion.inc.php");
    $connection = connect();

    $sql = "UPDATE tblAdmin SET
    email = \"$email\",
    username = \"$username\ ",
    password = \"$password\ "
    WHERE username = \"$username\ "
    ";
    echo $sql;
    $result = @mysql_query($s ql) or die("Couldn't execute query.");
    ?>
    <P>The following information was successfully updated in <? echo "tblAdmin"; ?></p>
    <table cellspacing=3 cellpadding=5>

    <tr>
    <td valign=top>
    <P><STRONG>emai l:</STRONG><BR>
    <?php echo "$email"; ?></P>

    <P><STRONG>Surn ame:</STRONG><BR>
    <?php echo "$username" ; ?></P>

    <P><STRONG>Pass word:</STRONG><BR>
    <?php echo "$password" ; ?></P>
    </td>
    </tr>
    <tr>
    <td align=center colspan=2><br>
    </TD>
    </TR>
    </TABLE>
    [/code]

    [Please use CODE tags when posting source code. Thanks! --pbmods]
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    Please use PHP tags. Get rid of the '@' symbol. And try to seperate you HTML PHP and MySql more clearly, if you do this there is rarely a need for escaping quotes.
    The problem. You are not reading the $_POST array to extract the posted variables. [PHP]$name = $_POST['username'];[/PHP]

    Comment

    Working...