inserting into a mysql database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Aido82
    New Member
    • Jan 2007
    • 3

    inserting into a mysql database

    Im having a problem inserting the following data into a Mysql table, just wondering if any one has any ideas on how to get it to work. When i click the register button nothing at all happens . any one got any ideas.



    <?php

    $connection = mysql_connect(" localhost", "root", "")
    or die ("Could not connect to server");

    $db = mysql_select_db ('customer', $connection) or die('could not connect to DB' .mysql_error()) ;

    $query = "INSERT INTO customerdetails (custID, userName, title, password, custFirstName, custLastName, email, address1, address2, address3, country, telephone) VALUES (4,'$u', PASSWORD('$p'), '','$fn', '$ln', '$e','', '', '', '', '')";

    ?>

    <form action="home.ph p"><fieldset >
    <legend>Enter your information in the form below:</legend>

    <p><b>First Name:</b> <input type="text" name="custFirst Name" size="15" maxlength="15" value="<?php if (isset($_POST['custFirstName'])) echo $_POST['custFirstName']; ?>" /></p>

    <p><b>Last Name:</b> <input type="text" name="custLastN ame" size="30" maxlength="30" value="<?php if (isset($_POST['custLastName'])) echo $_POST['custLastName']; ?>" /></p>

    <p><b>Email Address:</b> <input type="text" name="email" size="40" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /> </p>

    <p><b>User Name:</b> <input type="text" name="userName" size="10" maxlength="20" value="<?php if (isset($_POST['userName'])) echo $_POST['userName']; ?>" /></p>

    <p><b>Password: </b> <input type="password" name="password1 " size="20" maxlength="20" /></p>

    <p><b>Confirm Password:</b> <input type="password" name="password2 " size="20" maxlength="20" /></p>

    </fieldset>
    <div align="center"> <input type="submit" name="submit" value="Register " /></div>
    </form>
  • treecool
    New Member
    • Jan 2007
    • 6

    #2
    Code:
    $query = "INSERT INTO customerdetails (custID, userName, title, password, custFirstName, custLastName, email, address1, address2, address3, country, telephone) VALUES (4,'[B]$u[/B]', PASSWORD('[B]$p[/B]'),'','$fn', '$ln', '$e','', '', '', '', '')";
    it is mean that you are using
    '$u' variable for userName
    '$p' for title
    and so on... .

    Code:
     
     <p><b>First Name:</b> <input type="text" name="[B]custFirstName[/B]" size="15" maxlength="15" value="<?php if (isset($_POST['custFirstName'])) echo $_POST['custFirstName']; ?>" /></p>
    if you use "custFirstN ame" as your first name
    you must declare on the query

    and also the query is not send to the mysql with "mysql_quer y" command

    example

    Code:
    <?php
    $query=mysql_query("insert into costumerdetails (userID, firstName, lastName) values (4, '$firstName', '$lastName')");
    if($query) 
    echo "Register Complete";
    ?>
    <form action="" method="post">
    First Name <input type='text' name='firstName'><br>
    Last Name <input type="text" name=lastName'><br>
    <input type='submit' values='register'>
    </form>
    hope usefull... .

    Comment

    Working...