php simple insert form help need

chamarams

Well-known member
  • Nov 22, 2008
    1,908
    344
    83
    inside you hart :D
    i'm newbie for PHP and just try simple form but have issue with insert.php page first of all my db consist of 4 record (id ,name ,phonenumber,date) the id column is auto increment page .

    i create to display information to page call index php it's work well but the problem is insert.php page that page doesn't load and can not inset value and go to see new insert value in index php page


    PHP:
     <?php
            if(isset($_post['name'])){
                $mysqli = new mysqli('localhost','root','','interdet');
                $statement =$mysqli->prepare("INSERT INTO detectives(name)VALUES(?,?)";
                $statement->bind_param('ss',$_POST['name']);
                $statement->execute();
                echo "Done! <a href='index.php'>Go here see new detective </a>";
    
            }
            else {
                ?>
                <form action="insert.php" method="POST">
                <p>Name : <input type="text" name="name" /> <P>
                <p><input type="submit"/></p>
                </form>
    <?php   } ?>
     

    chamarams

    Well-known member
  • Nov 22, 2008
    1,908
    344
    83
    inside you hart :D
    අනේ මචෝ මම PHP එච්චර දන්නේ නැහැ මට database එකකට data inset කරන්න පොඩි ෆෝම් එකක් හැදුවා db එකේ තියන ඉන්ෆෝ display වෙන ෆෝම් එකනම් වැඩ කරනවා එත් inset එක වැඩ නැහැ ඒ කියන්නේ data යන්නේ නැහැ
    මොකද්ද අව්ල කියල කියපන්ලා
     
    Last edited:

    Ayeshlive

    Well-known member
  • Jul 1, 2011
    10,570
    943
    113
    *̶͑̾̾​̅ͫ͏̙̤g͛͆̾ͫ̑͆&
    Machan
    PHP:
    INSERT INTO detectives(name)VALUES(?,?)
    Methana query eka waradine.
    PHP:
    INSERT INTO detectives (name) VALUES (?)
    
    Params count ekai column count ekai samana wenna one. bing_param method ekedi "s" witharai one wenne.
    New entry eka ganna
    <font color="Red">
    PHP:
    $statement->insert_id
     
    Last edited:

    chamarams

    Well-known member
  • Nov 22, 2008
    1,908
    344
    83
    inside you hart :D
    thanks bro
    PHP:
    INSERT INTO detectives (name) VALUES (?)
    
    eka edit kala

    PHP:
    $statement->insert_id
    eka :confused:
    eka gananam mama danne na mata aluth entry ekak ganna one na
    oya statement waradi?
     
    Last edited:

    chamarams

    Well-known member
  • Nov 22, 2008
    1,908
    344
    83
    inside you hart :D
    PHP:
    <?php
    
    if(isset($_post['name'])){
    $mysqli = new mysqli('localhost','root','','interdet');
    $statement =$mysqli->prepare("INSERT INTO detectives(name)VALUES(?)");
    
    
    $statement->bind_param('ss',$_POST['name']);
    
    [SIZE="3"][COLOR="Indigo"]// මෙතනත් වෙනස් කරලා බැලුව $statement->bind_param('s',$_POST['name']);
    ඊත් හරියන්නේ නැහැ [/COLOR][/SIZE]
    $statement->execute();
    echo "Done! <a href='index.php'>Go here see new detective </a>";
    
    }else {
    ?>
    <form action="insert.php" method="POST">
    <p>Name : <input type="text" name="name" /> <P>
    <p><input type="submit"/></p>
    </form>
    
    <?php } ?>
     

    smother

    Well-known member
  • Jan 27, 2009
    19,902
    1,484
    113
    36
    Six Feet Under
    Machan
    PHP:
    INSERT INTO detectives(name)VALUES(?,?)
    Methana query eka waradine.
    PHP:
    INSERT INTO detectives (name) VALUES (?)
    
    Params count ekai column count ekai samana wenna one. bing_param method ekedi "s" witharai one wenne.
    New entry eka ganna
    <font color="Red">
    PHP:
    $statement->insert_id
    :yes::yes: