SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2000
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, newbie question here,

    I'm trying to use PHP and MySQL to implement a membership form....

    My initial page is addform.php3 :
    <form method="post" action="confirm.php3">
    <p>
    <font color="#00004D">First Name</font><br>
    <input type="text" name="FIRST_NAME"> </p>
    <p>Last Name<br>
    <input type="text" name="LAST_NAME">
    </p>
    <p>Password<br>
    <input type="password" name="PASSWORD">
    </p>
    <p>Email<br>
    <input type="text" name="EMAIL">
    </p>
    <p><input type="submit" name="Submit" value="Submit">
    <input type="reset" name="Submit2" value="Reset">
    </form>


    Which loads up "Confirm.php3", which looks like this:
    $server= "localhost"; //mysql server address
    $dbname= "mydbname"; // mysql database name
    $uid= "myusername"; // username for that database
    $pwd= "mypassword"; // password for that database

    if (($REQUEST_METHOD=='post')) {
    $query = "INSERT INTO MEMBERS";
    $query .= "(FIRST_NAME, LAST_NAME,";
    $query .= "EMAIL, PASSWORD)";
    $query .= "values('$FIRST_NAME','$LAST_NAME','$EMAIL','$PASSWORD')";

    $conn=mysql_connect($server,$uid,$pwd) or die("Unable to connect to SQL server");
    mysql_select_db($dbname, $conn) or die("Unable to select database");

    mysql_query($query) or die("Insert Failed!");


    However, this just doesn't seem to work! No members are added and I'm getting no errors. Could someone tell me what I'm doing wrong?

    thanks in advance,
    kankohi

  2. #2
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A couple of things here:

    1. Make sure the database is MEMBERS and not Members or members etc.

    2. Change the query to:
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>
    $query = "INSERT INTO MEMBERS";
    $query .= " (FIRST_NAME, LAST_NAME,";
    $query .= "EMAIL, PASSWORD)";
    $query .= " values ('$FIRST_NAME','$LAST_NAME','$EMAIL','$PASSWORD')";
    [/code]

    I hope these help you out.

    ------------------
    Karl Austin
    KDA Web Services

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2000
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the suggestions Karl,

    I tried that query but still no luck... no errors and it still doesn't add any members.

    thanks again,
    kankohi

  4. #4
    SitePoint Zealot
    Join Date
    Nov 1999
    Location
    Manhattan!
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When you get no error message, but it still does not work, then it is almost always because one of the fields do not match.

    When I have that problem, I go to my phpMyAdmin page and use it to insert a row into the table. I use the values $name, $password, $email (etc.) and insert the row.

    phpMyAdmin will then show the entire SQL string as part of the confirmation page. I just copy that string into my code and it works.

    Christian Reimer

    ------------------
    Axie automatically performs free, customizable searches for new
    websites and delivers the links to members by personalized email.
    http://www.axie.com/


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
  •