Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)

I have the following code to fetch the user data from the MySQL database and show it in a form for editing and saving. The issue is, it doesn't work. 

<html>
    <head>
        <title> Delegate edit form</title>
    </head>
    <body>
        Delegate update form  <p>
            <?php
            $usernm   = "root";
            $passwd   = "";
            $host     = "localhost";
            $database = "swift";

            //$Name=$_POST['Name'];
            //$Username=$_POST['User_name'];
            //$Password=$_POST['Password'];

            mysql_connect($host,$usernm,$passwd);

            mysql_select_db($database);

            $sql    = "SELECT * FROM usermaster WHERE User_name='$Username'";
            $result = mysql_query($sql) or die(mysql_error());
            while ($row    = mysql_fetch_array($result))
            {

                $Name     = $row['Name'];
                $Username = $row['User_name'];
                $Password = $row['User_password'];
            }
            ?>
        <form action="Delegate_update.php" method="post">
            Name
            <input type="text" name= "Name" value= "<?php echo $row ['Name']; ?> "size=10>
            Username
            <input type="text" name= "Username" value= "<?php echo $row ['Username']; ?> "size=10>
            Password
            <input type="text" name= "Password" value= "<?php echo $row ['Password']; ?>" size=17>
            <input type="submit" name= "submit" value="Update">
        </form>
    </body>
</html>

Any kind of help will be appreciated.

1 Answer

0 votes
by (12.7k points)

You can use the following code. You can concentrate on the concept, edit wherever necessary so that it can.

<html>
<head>
    <title> Delegate edit form</title>
</head>
<body>
    Delegate update form  </p>

    <meta name="viewport" content="width=device-width; initial-scale=1.0">

    <link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />


    <link href='http://fonts.googleapis.com/css?family=Droid+Serif|Ubuntu' rel='stylesheet' type='text/css'>

    <link rel="stylesheet" href="css/normalize.css">
    <link rel="stylesheet" href="js/flexslider/flexslider.css" />
    <link rel="stylesheet" href="css/basic-style.css">




    <script src="js/libs/modernizr-2.6.2.min.js"></script>

    </head>

    <body id="home">

        <header class="wrapper clearfix">



            <nav id="topnav" role="navigation">
                <div class="menu-toggle">Menu</div>
                <ul class="srt-menu" id="menu-main-navigation">
                    <li><a href="Swift_Landing.html">Home page</a></li>

        </header>
        </section>

        <style>
            form label {
                display: inline-block;
                width: 100px;
                font-weight: bold;
            }
        </style>
        </ul>

        <?php
        session_start();
        $usernm="root";
        $passwd="";
        $host="localhost";
        $database="swift";

        $Username=$_SESSION['myssession'];



        mysql_connect($host,$usernm,$passwd);

        mysql_select_db($database);

        $sql = "SELECT * FROM usermaster WHERE User_name='$Username'";
        $result = mysql_query ($sql) or die (mysql_error ());
        while ($row = mysql_fetch_array ($result)){

        ?>

        <form action="Delegate_update.php" method="post">
            Name
            <input type="text" name="Namex" value="<?php echo $row ['Name']; ?> " size=10>
            Username
            <input type="text" name="Username" value="<?php echo $row ['User_name']; ?> " size=10>
            Password
            <input type="text" name="Password" value="<?php echo $row ['User_password']; ?>" size=17>
            <input type="submit" name="submit" value="Update">
        </form>
        <?php
        }
        ?>
        </p>
    </body>
</html>

Want to become a SQL Expertise? You can register to this SQL Course and get certified.

Related questions

0 votes
1 answer
asked Jan 1, 2021 in SQL by Appu (6.1k points)
0 votes
1 answer
asked Dec 31, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer
asked Dec 19, 2020 in SQL by Appu (6.1k points)

Browse Categories

...