i m trying to insert data in mysql with php but afther writen code data not submited

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saqi
    New Member
    • Aug 2013
    • 1

    #1

    i m trying to insert data in mysql with php but afther writen code data not submited

    Code:
    <html> <head><title>my form</title></head> <body bgcolor="gray"> <br><br><br><br><br><br> <dive align="center"> <form method="post" action="<?php $_php_self?>">
    username<input type="text" name="username"><br />
    email<input type="text" name="email"><br /> <input type="submit" name="submit"> </center> </body> </html> <?php
    
    if(isset($_POST['submit']));
    {
    $username=$_POST['username'];
    $email=$_POST['email'];
    
    /*variable define to the server and host*/
    
    $localhost="localhost";
    $username="root";
    $password="";
    $tbl_name="user_values";
    /*connect to the database*/
    $con=mysql_connect('localhost','root','','user_values') or die("cannot connect");
    $find_db=mysql_select_db("os_1",$con)or die("cannot connect DB");
    
    /*get values form form*/
    $name=$_POST['username'];
    $email=$_POST['email'];
    /*insert values html form to mysql database*/
    
    mysql_query("INSERT INTO user_values 
    (u_name, email, pwd) VALUES('username', 'email' ) ") or die(mysql_error());  
    
    echo "Data Inserted!";
    
    }
    
    
    
    ?>
    Last edited by Rabbit; Aug 27 '13, 02:55 PM. Reason: Please use code tags when posting code.
  • Exequiel
    Contributor
    • Jul 2012
    • 288

    #2
    its not working because the pwd didnot determin in your insertion, you didnot put the value for pwd, try to put the value for pwd, like this code. . .
    Code:
    mysql_query("INSERT INTO user_values 
    (u_name, email, pwd) VALUES('username', 'email', 'yourpwd') ") or die(mysql_error());

    Comment

    • Ammu
      New Member
      • Aug 2011
      • 78

      #3
      in your insert query where is the value for the field "pwd"?
      and you get posted values to $name and $email.
      so your code should be like this

      Code:
      $pwd = $_post[''];
      mysql_query("INSERT INTO user_values 
      (u_name, email, pwd) VALUES('$name', '$email' ,'$pwd' ) ") or die(mysql_error());

      Comment

      • hosting charges
        New Member
        • Aug 2013
        • 10

        #4
        Please do not post your DB user name and password in public forum.

        Comment

        Working...