By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,953 Members | 1,054 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,953 IT Pros & Developers. It's quick & easy.

PHP will not post to next form

P: 32
hi all.

I have 3 files:-

Pick_moduser.php
do_moduser.php
show_moduser.php

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.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     include("connection.inc.php");
  3.         $connection = connect();
  4.  
  5.     $sql = "SELECT email, username, password
  6.                 FROM tblAdmin
  7.                 ORDER BY email";
  8.  
  9.     $result = @mysql_query($sql) or 
  10.     die("Couldn't execute query.");
  11.  
  12.     $option_block = "";
  13.  
  14.     while ($row = mysql_fetch_array($result))
  15.     {
  16.         $email = $row['email'];
  17.         $username = $row['username'];
  18.         $password = $row['password'];
  19.  
  20. $option_block .= "<option value=\"$username\">$username, $email, $password</option>";
  21.     }
  22. $display_block = "
  23.  
  24.             <form method=\"post\" action=\"show_moduser.php\">
  25.  
  26.         <p><strong>contact:</strong>
  27.         <select name=\"username\">
  28.                 $option_block
  29.         </select>
  30.  
  31.         <input type=\"submit\" name=\"submit\" 
  32.             value=\"select this user\"></p>
  33.         </form>
  34.         ";
  35.  
  36. ?>
  37. <h3>Modify a User</h3>
  38. <P>Select a user from the list below, to modify the user's record.</p>
  39.  
  40. <?php echo "$display_block"; ?>
  41.  
show_moduser.php

Expand|Select|Wrap|Line Numbers
  1. <form method="post" action="do_moduser.php">
  2. <input type="hidden" name="username"
  3.     value="<?php echo "$username";?>">
  4. <table cellspacing=3 cellpadding=5 width="532">
  5. <tr>
  6. <td valign=top>
  7. <p><strong>email:</strong><br>
  8. <input type="text" name="email" value="<? echo "$email";?>" size=35 maxlength=75></p>
  9.  
  10. <p><strong>username:</strong><br>
  11. <input type="text" name="username"  
  12.     value="<? echo "$username";?>" size=35 maxlength=75></p>
  13.  
  14. <p><strong>password:</strong><br>
  15. <input type="text" name="password"  
  16.     value="<? echo "$password";?>" size=35 maxlength=75></p>
  17. </td>
  18. </tr>
  19. <tr>
  20. <td align=center width="516"><p><input type="submit" name="submit" value="update user information"></p>
  21. </td>
  22. </tr>
  23. </table>
  24. </form>
  25.  
  26.  
  27. Do_moduser.php
  28.  
  29. <?php
  30.     include("connection.inc.php");
  31.     $connection = connect();
  32.  
  33.     $sql = "UPDATE tblAdmin SET 
  34.         email = \"$email\", 
  35.         username = \"$username\", 
  36.         password = \"$password\" 
  37.         WHERE username = \"$username\"
  38.         ";
  39.     echo $sql;
  40.     $result = @mysql_query($sql) or die("Couldn't execute query.");
  41. ?>
  42. <P>The following information was successfully updated in <? echo "tblAdmin"; ?></p>
  43. <table cellspacing=3 cellpadding=5>
  44.  
  45. <tr>
  46. <td valign=top>
  47. <P><STRONG>email:</STRONG><BR>
  48.     <?php echo "$email"; ?></P>
  49.  
  50. <P><STRONG>Surname:</STRONG><BR>
  51.     <?php echo "$username"; ?></P>
  52.  
  53. <P><STRONG>Password:</STRONG><BR>
  54.     <?php echo "$password"; ?></P>
  55. </td>
  56. </tr>
  57. <tr>
  58. <td align=center colspan=2><br>
  59. </TD>
  60. </TR>
  61. </TABLE>
  62.  
[Please use CODE tags when posting source code. Thanks! --pbmods]
May 21 '07 #1
Share this Question
Share on Google+
1 Reply


code green
Expert 100+
P: 1,726
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]
May 21 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.