-4

I am creating a login system, a data update system in which can update the information of a login account.

First, input the login name of the account you want to change:

UPDATEINPUT.HTML

<html>

<form method = "get" action ="update.php">

ID:<input type = "text" name="logid" >

<input type = "submit" value ="update choose">
</form>

</html>

then, I get the input value:

INPUT.PHP

<h1>Update Student</h1>

<a href="index.php">Back to Main Menu</a><p>


<?php

   $loginid = $_POST['logid'];


  $con = mysql_connect("127.0.0.1","root","password");

  mysql_select_db("babytradeapps");

  $sql = "Select * from customerlist where LoginID = '$loginid'";

  $results = mysql_query($sql,$con);

  $row = mysql_fetch_array($results);


   $loginidd = $row[0];
   $Password = $row[1];
   $Name = $row[2];
   $Phone = $row[3];
   $IDCARDNO = $row[4];
   $Email = $row[5];
   $BankACNO = $row[6];
   $Plan = $row[7];
   $Date = $row[8];



   if(mysql_query($sql))

  {
               echo 'success';


        }
        else
        {
                echo 'fail!';

        }


echo mysql_error()


?>


<form method="get" action="updatecheck.php">

  ID: <?php echo $loginidd; ?></p>

  Password:<input type="text" name="Password" value="<?php  echo $Password; ?>" /><p>

  Name:<input type="text" name="Name" value="<?php  echo $Name; ?>" /><p>

  Phone:<input type="text" name="Phone" value="<?php  echo $Phone; ?>" /><p>

  IDCARDNO:<input type="text" name="IDCARDNO" value="<?php  echo $IDCARDNO; ?>" /><p>

  Email:<input type="text" name="Email" value="<?php  echo $Email; ?>" /><p>

  BankACNO:<input type="text" name="BankACNO" value="<?php  echo $BankACNO; ?>" /><p>

  Plan:<input type="text" name="Plan" value="<?php  echo $Plan; ?>" /><p>

  Date:<input type="text" name="Date" value="<?php  echo $Date; ?>" /><p>

  <input type="submit" class="submit" value="Login"/></tr></td>
  </form>

but there's no action of:

**

$loginidd = $row[0];
$Password = $row[1];
$Name = $row[2];
$Phone = $row[3];
$IDCARDNO = $row[4];
$Email = $row[5];
$BankACNO = $row[6];
$Plan = $row[7];
$Date = $row[8];

**

PHP

CREATE TABLE customerlist
(
  C_Id INT auto_increment,
  LoginID VARCHAR(10),
  Password VARCHAR(20) ,
  Name VARCHAR(20),
  Phone VARCHAR(15),
  IDCARDNO VARCHAR(15),
  Email VARCHAR(30),
  BankACNO VARCHAR(18),
  Plan VARCHAR(4),
  Date VARCHAR,
  PRIMARY KEY (C_Id),
  UNIQUE (LoginID)
);
Dave Chen
  • 10,887
  • 8
  • 39
  • 67

2 Answers2

1

Your form is sending as GET yet you're trying to access the data via POST.

Try this:

<form method = "post" action ="update.php">

ID:<input type = "text" name="logid" >

<input type = "submit" value ="update choose">
</form>

NOTES

Community
  • 1
  • 1
Darren
  • 13,050
  • 4
  • 41
  • 79
0

As mentioned above, your form sends a GET request but you access the $_POST varialbe. There is $_GET also available in PHP. Or you can change the form method to post.

Try using:

var_dump($yourvarialbe)

to see if it has the values you expect. For example here if you did

var_dump($_POST)

you would see that it's empty and that's why your code does not work.

Sudavar
  • 71
  • 4