Help Me for registration and log in

Discussion in 'PHP' started by salayhin, Jan 14, 2010.

  1. #1
    I have a problem in my user registration....when i input and submit data last line of "Thanks For Registration." print but no insert in data base..
    What is the error..

    Please help me...and plz code the line how would i check either the data is insert or not in database....
    Here is the code.
    #########################################

    <?

    $dbhost = 'localhost';
    $dbuser = 'hindimus_shippin';
    $dbpass = 'Ashawon4742';
    $dbname = 'hindimus_wasimShipping';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass)
    or die ('Error Connecting to Database');

    mysql_select_db($dbname)
    or die("Could Not Select Database");

    //require("../connection.php");
    $query="INSERT INTO user_reg (country_id, business_type, first_name, last_name, company_name, ph_num, com_description, email, password, re_password,username ) VALUES ('".$_POST["country"]."', '".$_POST["accounttype"]."', '".$_POST["first_name"]."', '".$_POST["last_name"]."', '".$_POST["company_name"]."', '".$_POST["pn_num"]."', '".$_POST["com_description"]."', '".$_POST["email"]."', '".$_POST["password"]."', '".$_POST["re_password"]."', '".$_POST["username"]."')";
    mysql_query($query,$conn);
    print("Thanks For Registration...");
    //print("<script language=\"JavaScript\"> window.location=\"index.php?script=login\";</script>");
    ?>
     
    salayhin, Jan 14, 2010 IP
  2. dsignresponder

    dsignresponder Greenhorn

    Messages:
    81
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    18
    #2
    Hi salayhin,

    1. it's not a very good idea to post your REAL dbname, dbusername, passwords, etc. here.... use some general values i.e. my_dbname, my_username, etc.

    2. instead of your query
    
    $query="INSERT INTO user_reg (country_id, business_type, first_name, last_name, company_name, ph_num, com_description, email, password, re_password,username ) VALUES ('".$_POST["country"]."', '".$_POST["accounttype"]."', '".$_POST["first_name"]."', '".$_POST["last_name"]."', '".$_POST["company_name"]."', '".$_POST["pn_num"]."', '".$_POST["com_description"]."', '".$_POST["email"]."', '".$_POST["password"]."', '".$_POST["re_password"]."', '".$_POST["username"]."')";
    
    Code (markup):
    use this :
    
    $country = $_POST['country'];
    $accounttype = $_POST['accounttype'];
    $username = $_POST['username'];
    
    $query = "INSERT INTO user_reg SET
    			country_id = '$country',
    			business_type = '$accounttype',
    			username = '$username' ";
    
    Code (markup):
    NOTE : I haven't typed ALL the values but I think you got the point! ;)

    3. Don't just execute the query like
    
    mysql_query($query,$conn);
    
    Code (markup):
    instead use :
    
    if (mysql_query($query)) {
    print("Thanks For Registration...");
    }
    
    Code (markup):
    or
    
    mysql_query($query) or error(mysql_error());
    
    Code (markup):
    Hope this will help.....
    Best regards
    :)
     
    dsignresponder, Jan 14, 2010 IP