SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    USA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form help cont...

    this a continuation of this thread..... but you would be able to see, we changed focus in the middle of it.... so, i decided to start a new thread for those of you that come in the middle of the "action".....

    Quick Expla...
    I was trying to read data from this form http://nbrec.com/salsenrollment.html and store it into a MySql db...

    The following is the code that i was priviously provided.... Thanxs in advance...

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    USA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?php
    $dbhost = "125.0.0.1";
    $dbuser = "nbrec";
    $dbpass = "mwhitexxx";
    $dbname = "nbrec_com_-_db";

    $connect = mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error());
    mysql_select_db("$dbname", $connect) or die(mysql_error());

    mysql_query('INSERT INTO RegistrationTBL VALUES ('NULL', "'.$_POST['name'].'", "'.$_POST['lname'].'", "'.$_POST['email'].'", "'.$_POST['sex'].'","'.$_POST['age'].'","'.$_POST['address'].'","'.$_POST['city'].'","'.$_POST['zip'].'","'.$_POST['state'].'","'.$_POST['phnum'].'","'.$_POST['TeamName'].'","'.$_POST['CoachName'].'")');
    $resultat = mysql_query($ret);
    mysql_close($connect);
    ?>

  3. #3
    Non-Member hyperimage's Avatar
    Join Date
    Dec 2003
    Location
    Croatia
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php 
    //connect config data
    $dbhost "125.0.0.1"
    $dbuser "nbrec"
    $dbpass "mwhitexxx"
    $dbname "nbrec_com_-_db"

    //mysql connect form 
    $connect mysql_connect("$dbhost""$dbuser""$dbpass") or die(mysql_error()); 
    mysql_select_db("$dbname"$connect) or die(mysql_error()); 

    //calleing function on submit button
    if(isset($_POST["your_submit_button_name"])) update();
    // or
    if(!empty($_POST["your_submit_button_name"])) update();

    //executive function on submit button
    function update()
    {
    if(
    $_POST["name"]!="")
    {
    $ret "INSERT INTO RegistrationTBL VALUES('', '$name', '$lname', '$email', '$sex', '$age', '$address', '$city', '$zip', '$state', '$phnum', '$TeamName', '$CoachName']";
    $resultat mysql_close($connect);
    mysql_query($ret); 
    echo 
    "Data inserted sucessfully!";
    } else {
    echo 
    "Inserting data problems!";
    }

    ?>
    thats it!!
    cya
    Last edited by hyperimage; Feb 24, 2004 at 13:48.

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    USA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    gives an erro on this line:
    mysql_close($connect);

    i commented it out just to debug it.. and it seems to work b/c it gives you the "Data inserted sucessfully!" message...but there's nothing being inserted into the db...

    don't you have to pre-declare the variables using the content of the form fields b4 inserting it into the bd.

    if you want to test it... this is the link to the form..
    http://nbrec.com/salsenrollment.html

    and this is the link to the pg that shows you the content of the db..
    http://nbrec.com/Good_output.php

  5. #5
    Non-Member hyperimage's Avatar
    Join Date
    Dec 2003
    Location
    Croatia
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try it now it must work!!!!
    i modificated it!
    it have a simply type error couse i was fast to type it and i make an error!!!

    see ya

  6. #6
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    USA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    code didn't work

    nope...still gives an erro on line ....mysql_query($ret);
    but again i commented it out and appears to do it but still nothing is entered into the db...
    thanxs anyways...


    // this is the code as i'm using it....the only modification i made was the name button name

    <?php
    //connect config data
    $dbhost = "125.0.0.1";
    $dbuser = "nbrec";
    $dbpass = "mwhitexxx";
    $dbname = "nbrec_com_-_db";

    //mysql connect form
    $connect = mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error());
    mysql_select_db("$dbname", $connect) or die(mysql_error());

    //calleing function on submit button
    if(isset($_POST["submitREGbt"])) update(); //modified line
    // or
    if(!empty($_POST["submitREGbt"])) update(); //modified line

    //executive function on submit button
    function update()
    {
    if($_POST["submitREGbt"]!="") //modified line
    {
    $ret = "INSERT INTO RegistrationTBL VALUES('', '$name', '$lname', '$email', '$sex', '$age', '$address', '$city', '$zip', '$state', '$phnum', '$TeamName', '$CoachName']";
    $resultat = mysql_close($connect);
    mysql_query($ret); // this line gives an error
    echo "Data inserted sucessfully!";
    } else {
    echo "Inserting data problems!";
    }
    }
    ?>

  7. #7
    Non-Member hyperimage's Avatar
    Join Date
    Dec 2003
    Location
    Croatia
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you made an error on insert form...and i havent pay attention!
    ok now it must work 300%!!!
    PHP Code:
    <?php 
    //connect config data 
    $dbhost "125.0.0.1"
    $dbuser "nbrec"
    $dbpass "mwhitexxx"
    $dbname "nbrec_com_-_db"
    //mysql connect form 
    $connect mysql_connect("$dbhost""$dbuser""$dbpass") or die(mysql_error()); 
    mysql_select_db("$dbname"$connect) or die(mysql_error()); 
    //calling function on submit button 
    if(isset($_POST["your_submit_button_name"])) update(); 
     
    //executive function on submit button 
    function update() 

    if(
    $_POST["name"]!=""

    //mysql insert form
    $ret "INSERT INTO RegistrationTBL VALUES('', '$name', '$lname', '$email', '$sex', '$age', '$address', '$city', '$zip', '$state', '$phnum', '$TeamName', '$CoachName']"
    $resultat mysql_query($ret);  // You have made wrong
    mysql_close($connect);          // these 2 lines :)
    echo "Data inserted sucessfully!"
    } else { 
    echo 
    "Inserting data problems!"


    ?>
    cya

  8. #8
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    USA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks !!


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
  •