SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    NYC
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cannot Post Record Via Form....help

    Hello,

    TESTING MACHINE:

    DB: MYSQL 5.0
    PHP: 5.02
    OS XP SP2

    I have a simple one field html form which has a FIRSTNAME text field with a submit button. I have action script (addrecord.php) which action invokes when user submit the forms. I am able to see all the tables and can insert data from command line but when I call up the html form and key in first name (all character) I get a FILE DOWNLOAD POP which suggest either I can open the ADDRECORD.PHP OR SAVE IT LOCALLY.

    PHP is up and running with IIS 5.1 and my phpinfo.php shows all the details. I am able to connect to the database and echo the status but SQL does not get anywhere.

    If I open the ADDRECORD HTML form in DREAMWEAVER and publish it via browser and insert a name via ADDREC.HTM while dreamweaver is open in the back, I have no problems doing so. Once I close it (Dreamweaver) I am unable to insert any data onto the DB.

    I am including both of my codes and hope someone can point me to the right direction. Any help would be wonderful.

    Thanks.


    HTML FORM---------------------------------------------------

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>

    <body>
    <form id="form1" name="form1" method="post" action="addrecord.php">
    <label>First Name<br />
    <input type="text" name="FIRSTNAME" id="FIRSTNAME"/>
    </label>
    <br />
    <br />
    <label>
    <input type="submit" name="Submit" value="Submit" />
    </label>
    </form>
    </body>
    </html>

    -------------------------------------------------------------------------



    ADDRECORD.PHP--------------------------------------------------------


    <?php

    error_reporting(E_ALL ^ E_NOTICE);

    $db_name = "testdb";
    $table_name = "usertable";


    $connection = @mysql_connect("localhost", "root", "butterfly007")

    or die (@mysql_error());


    $db = @mysql_select_db($db_name,$connection) or die (@mysql_error());

    $sql="INSERT INTO $table_name(FIRSTNAME) VALUES ('$_POST[FIRSTNAME]')";

    $result = mysql_query($sql,$connection) or die (@mysql_error());

    ?>


    <html>
    <head>
    <title>STATUS</title>

    <body>

    <?php echo "$msg"; ?>

    </body>

    </html>

    Thanks.

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $sql="INSERT INTO $table_name (FIRSTNAME) VALUES ('{$_POST[FIRSTNAME]}')"
    also, remove @ from mysql_error()

  3. #3
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try with http://localhost/ in your browser to test whether your web server is running properly or not? And did you install the PHP in your IIS? The problem that you are facing comes if you have not installed your PHP in the IIS and configured yet. If you have installed PHP you must have selected the correct IIS version for your PHP.

    Be sure of that you have installed PHP or not.

  4. #4
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rajug View Post
    Be sure of that you have installed PHP or not.
    you did see the part where ultrajeeps says that phpinfo works, right?

  5. #5
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by longneck View Post
    you did see the part where ultrajeeps says that phpinfo works, right?
    Oh yes. sorry. I had problem at my beginning phase so i directly posted reply.

    But i m sure that the web server says to download the .php files if it does not know to parse with PHP. Am i right longneck?

  6. #6
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    ah, that i missed, too. weird.

  7. #7
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    NYC
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Still no progress

    Hello longneck and rajug,

    First of all thanks a lot for your help. I have applied longneck's suggested $sql syntax and
    have taken all @ out but still no progress. Since then I have tried numerous ways of and still
    dead end. All my extension are active and am able to connect to database. I have checked the
    installed IIS 5.1 server which has the php-cgi active with php extension. Now I am considering
    unistalling IIS and installing Apache 2.2 and see how things pan out.

    Will update very soon.

    Thanks.

  8. #8
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes that would be the better way to use the Apache web server instead of IIS for PHP. Am i right longneck?

  9. #9
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    NYC
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Figured out the issue

    Thank you for all your help. I figured out what I had been doing wrong to keep running into this issue. I had been opening up the HTML form by double clicking on it whereas it should be opened not by double clicking but calling it from the open browser window like this:

    http://localhost/test/addrec.htm

    test is the directory where the addrec.htm for is located. Once I did that, I was able to post data onto the database.

    Thanks.
    Ultrajeeps


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
  •