#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    7
    Rep Power
    0
    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
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    1
    Rep Power
    0
    Greetings,
    I am also a bit of a newbie but consider adding an else to the conditional statement to test if the first condition is evaluating false, as it is if this:

    if (($REQUEST_METHOD=='post')) {

    fails (that is if it evaluates false), then execution will stop and you will get no errors and no users added to your DB. Also I'm not sure you need (( *** )) double parens around the conditional statement it's not "if ((this &#0124; &#0124; (this)) {}"... it's
    "if (this) {}"...
    Otherwise looks fine to me.
    Best
    Scott

  4. #3
  5. No Profile Picture
    try a linux desktop today!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    Vancouver
    Posts
    23
    Rep Power
    0
    Hi,

    I'm real green, and am trying to do a membership system as well. I have my registration form much like yours with a couple differences.

    Not sure why yer asking 'if((REQUEST...' - I have used the get method from my form which works.

    The other difference is that I haven't built up my query as you. "$query .="

    I just wrote one long line with my column names $tablename (firstName,lastName...) hit 'return' and did VALUES ('$firstName','$lastName'...)"; closing with "; It is my understanding that php does not care about line breaks unless it sees the ';'.

    Your approach may certainly be valid (I wouldn't know ) but I do know mine works.

    Jay
  6. #4
  7. No Profile Picture
    try a linux desktop today!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    Vancouver
    Posts
    23
    Rep Power
    0
    Sorry, addendum

    What I meant is that I don't nest my connection stuff in an 'if' statement. It's just there and runs as it reads.

    JB
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    4
    Rep Power
    0
    Hi all,

    I just wonder, why did you try to check the "if" condition using "$REQUEST_MODE". In my day programming I ussually use the button name to validate.

    This makes easy to determine which button is pressed when there are more than 1 button. To catch the button name I check with "if ($btn_name) ...".

    But if there is a special purpose to use "$REQUEST_MODE" can you explain more?

    Regards,
    enka
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    7
    Rep Power
    0
    Thanks for all your help,

    I got it to work, just changed $Request_method = "post" to "get"

    again, my thanks,
    kankohi

Similar Threads

  1. PHP/MySQL Application Design/Architecture Books
    By glambert in forum PHP Development
    Replies: 7
    Last Post: April 10th, 2003, 09:52 PM
  2. PHP/MySQL Issues... Please help.
    By misteraven in forum PHP Development
    Replies: 14
    Last Post: August 7th, 2002, 08:03 PM
  3. Help! Perl, .htaccess and membership scripts
    By adam2000 in forum Perl Programming
    Replies: 1
    Last Post: July 1st, 2002, 05:42 PM
  4. PHP/MySQL Backend
    By Cujo in forum PHP Development
    Replies: 4
    Last Post: May 15th, 2002, 08:00 PM
  5. Need Qualified PHP/MySQL Programmer
    By ITGL72 in forum PHP Development
    Replies: 0
    Last Post: February 18th, 2002, 11:47 AM

IMN logo majestic logo threadwatch logo seochat tools logo