SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Aug 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP database upload

    Hi Again,

    I was wondering if somebody could help me see why I am getting this problem. I have written the program below but when I run it only certain fields will update with the values entered. All other fields will update but the address.

    Thanks for the help: -

    the html code is: -
    HTML Code:
    <form action="user.php" method="post">
        <table border="1">
        	<tr>
                <td>Name</td>
                <td><input type="text" name="FullName" /></td>
                <td>Address</td>
                <td><input type="text" name"address"/></td>
            </tr>
            <tr>
                <td>Date of Joining</td>
                <td><input type="text" name="Date"/></td>
                <td>Telephone Number</td>
                <td><input type="text" name="tele"/></td>
            </tr>
            <tr>
                <td>Email</td>
                <td><input type="text" name="email"/></td>
                <td>UserName</td>
                <td><input type="text" name="User"/></td>
            </tr>
            <tr>
                <td></td>
                <td>Password</td>
                <td><input type="text" name="pass" /></td>
            </tr>
        	<tr>
                <td colspan="4" style="text-align:center;"><input type="submit" value="Add Staff" /></td>
            </tr>
        </table>
        </form>
    my user.php program is: -

    PHP Code:
    <?php
    //connect to the database
    $con mysql_connect("servername","username","password");
      if (!
    $con//states that if connection can't be established run the error
      
    {
      die(
    'Could not connect:'.mysql_error());
      }
    //link to the database Klinic_ganga_stock_system
    mysql_select_db("Klinic_ganga_stock_system"$con);
    //add the details from adminpage.html add new staff the the table staff_record
    $sql "INSERT INTO staff_record (Name,Address,Date_of_joining,Telphone_number,Email,UserName,Password)
        VALUES 
    ('
    $_POST[FullName]','$_POST[address]','$_POST[Date]','$_POST[tele]','$_POST[email]','$_POST[User]','$_POST[pass]')";
    //run the query
    if (!mysql_query($sql,$con)){//this states that if the query can not be run then it will print the error
        
    die('Error:'.mysql_error());
      }
      else {
          print
    "Information added";
          }
     
    //close the connection
     
    mysql_close($con)
    ?>
    thanks guys
    Last edited by ScallioXTX; Jan 9, 2011 at 17:50. Reason: applied code tags

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,080
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Instead of name"address", try name="address"
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Also, be sure to escape your input fields (using something like mysql_real_escape_string). That code can be exploited very easily to ruin your database. Event better, use PDO.

  4. #4
    SitePoint Member
    Join Date
    Aug 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Guys, needed a fresh pair of eyes


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •