Update PHP Query not working...

Discussion in 'PHP' started by Majo0od, Feb 3, 2010.

  1. #1
    Hey guys,
    The query for updating a $_POST form isn't working, instead, it goes all blank...
    Here is the code:

    <?php
    include 'sql/dbcon.php';
    
    $userstuff= mysql_query("SELECT * FROM users");
    while($user = mysql_fetch_array($userstuff))
    {
    	?>
    	<div id = users>
    	<form>
        Username:
        <input type='text' name='Username' value='<?php echo $user[0];?>' />
        Password:
        <input type='text' name='Password' value='<?php echo md5($user[1]);?>' />
        Paypal/E-mail:
        <input type='text' name='Paypal' value='<?php echo $user[2];?>' />
        <br />
        Account Type<font size = 1>(MasterAdmin/Admin/blank for normal)</font>:
        <input type='text' name='AccountType' value='<?php echo $user[3];?>' />
        <br />
        Allow Admin to Register Users(Yes/blank):
        <input type='text' name='Allow' value='<?php echo $user[4];?>' />
        <br />
        Money: $
        <input type='text' name='Money' value='<?php echo $user[5];?>' />
        User ID:
        <input type='text' name='ID' value='<?php echo $user[6];?>' readonly='readonly'/>
        <br />
        <input type="submit" name="Update" id="Update" value="Update" />
        <input type="submit" name="Delete" id="Delete" value="Delete" />
        </form>
    	</div>
    	<br />
        <?php
    }
    if($_REQUEST['Update'])
    {
    	$Username=$_POST['Username'];
    	$Password=$_POST['Password'];
    	$Paypal=$_POST['Paypal'];
    	$AccountType=$_POST['AccountType'];
    	$AllowAdmin=$_POST['Allow'];
    	$Money=$_POST['Money'];
    	$ID=$_POST['ID'];
    	$query = "UPDATE users SET Username='$Username', Password='$Password', PayPal='$Paypal', Acctype='$AccountType', CreateUsers='$AllowAdmin', Money='$Money' LIMIT 1";
    	mysql_query($query) or die(mysql_error());
    }
    Code (markup):
    I really don't know whats wrong...

    Thanks guys,

    Majo0od
     
    Majo0od, Feb 3, 2010 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    put this at the top of your script. It sounds like you have error reporting disabled
    error_reporting(E_ALL ^ E_NOTICE);
    ini_set('display_errors', 1);
    PHP:
     
    JAY6390, Feb 3, 2010 IP
  3. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #3
    error is in the form tag
    use this
    
    <form method="post" name="frm1" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    
    Code (markup):
     
    javaongsan, Feb 3, 2010 IP
  4. Majo0od

    Majo0od Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks!! That worked :)
     
    Majo0od, Feb 3, 2010 IP