unable to insert data into database through php , using xampp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arushibafna
    New Member
    • Nov 2009
    • 8

    unable to insert data into database through php , using xampp

    hello,
    i am new to php , and recently installed xampp for my project purpose.
    i have been facing a problem for quite some time now and unable to find any solution. and as a result, my project is at halt.
    i have made a registration form in html&css and which is connected to my php page. the problem is that the changes are not occuring in my database. whenever i click submit , it show me the result but with no values being added to my database. just a blank row appears there.

    i have tried various formats for the QUERY part with different combination of single quotes and double quotes but none worked out for me.
    please let me know the changes required in $query.
    waiting for a reply.
    thank you.
    Attached Files
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Please see the mysqli_error() function/method. If you SQL fails, PHP will not notify you - you have to reveal the errors yourself.

    Comment

    • arushibafna
      New Member
      • Nov 2009
      • 8

      #3
      hello,
      well , i just tried printing the values of my variables before the database connection but it does not print any variable values. so does that mean that my values from html page are not getting transferred to my php page?

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by arushibafna
        hello,
        well , i just tried printing the values of my variables before the database connection but it does not print any variable values. so does that mean that my values from html page are not getting transferred to my php page?
        Most likely. Can we see the HTML page, please? Wrap the code in [CODE] tags.

        Example:
        [code]
        your html here
        [/code]

        Comment

        • arushibafna
          New Member
          • Nov 2009
          • 8

          #5
          Code:
          <!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">
          <!-- DW6 -->
          <head>
          <!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
          <title>Add Faculty</title>
          <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
          <link rel="stylesheet" href="mm_entertainment.css" type="text/css" />
          <style type="text/css">
          <!--
          .style1 {
          	color: #FFFFFF;
          	font-size: 24px;
          }
          .style3 {
          	font-size: 16px;
          	font-weight: bold;
          }
          .style4 {font-family: Arial, Helvetica, sans-serif}
          -->
          </style>
          </head>
          <body bgcolor="#14285f">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            
            <tr bgcolor="02021E">
              <td colspan="2" nowrap="nowrap"><img src="JECRC Pics/logo.jpg" alt="logo" width="227" height="145" /></td>
          
              <td height="39" valign="top" nowrap="nowrap" id="tagline"><img src="cooltext434699405.jpg" alt="name" width="1065" height="147" /><br />	  </td>
          	<td width="30">&nbsp;</td>
            </tr>
            
          
             <tr>
              <td colspan="4"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
            </tr>
          
             <tr>
          
              <td colspan="4" bgcolor="#cc3300"><img src="mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
          
            </tr>
          
            <tr>
              <td colspan="4" id="dateformat">&nbsp;<br />
          	&nbsp; &nbsp; <a href="homepage2.html">Home</a><a href="javascript:;"></a><br />	</td>
            </tr>
          
            <tr>
          
              <td width="271" valign="top">&nbsp;</td>
             <td colspan="2" valign="top"><br />
          	<table width="507" height="578" border="0" cellpadding="2" cellspacing="0">
                  <tr>
                    <td width="789" height="88" class="subHeader style1"><div align="center"></div>
                    <blockquote>
                      <p align="center" class="style4">Add Faculty </p>
          
                    </blockquote></td>
          
                  </tr>
                  
                  <tr>
                    <td class="bodyText"><div align="justify">
                      <blockquote>
                        <blockquote>
                          <blockquote>
                            <p><span class="style3"> Name:</span></p>
          
                          </blockquote>
          
                        </blockquote>
                      </blockquote>
                    </div></td>
                    <td height="79" class="bodyText"><form id="name" name="name" method="post" action="admin_addfac.php">
                      <label>
          
                        <div align="left">
                          <input name="name" type="text" id="name" />
          
                          </div>
          
                        </label>
                    </form>          </td>
                  </tr>
          	<tr>
                    <td class="bodyText"><div align="justify">
                      <blockquote>
                        <blockquote>
          
                          <blockquote>
          
                            <p><span class="style3">Username:</span></p>
                          </blockquote>
                        </blockquote>
                      </blockquote>
                    </div></td>
                    <td height="72" class="bodyText"><form id="username" name="username" method="post" action="admin_addfac.php">
                      <label>
          
                        <div align="left">
          
                          <input name="username" type="text" id="username" />
                          </div>
                        </label>
                    </form>          </td>
                  </tr>
          
                  <tr>
          
                    <td class="bodyText"><div align="justify">
                      <blockquote>
                        <blockquote>
                          <blockquote>
          
                            <p><span class="style3">Password:</span></p>
                          </blockquote>
                        </blockquote>
                      </blockquote>
          
                    </div></td>
                    <td height="72" class="bodyText"><form id="password" name="password" method="post" action="admin_addfac.php">
                      <label>
          
                        <div align="left">
          
                          <input name="password" type="password" id="password" />
                          </div>
                        </label>
                    </form>          </td>
          
                  </tr>
                  <tr>
                    <td class="bodyText"><div align="justify">
                      <blockquote>
          
                        <blockquote>
                          <blockquote>
                            <p><span class="style3">Dept:</span></p>
                          </blockquote>
          
                        </blockquote>
                      </blockquote>
                    </div></td>
                    <td height="73" class="bodyText"><form id="dept" name="dept" method="post" action="admin_addfac.php">
          
                      <label>
          
                        <div align="left">
                          <label>
                          <select name="dept" id="dept">
          
                            <option>Computer Science</option>
                            <option>Electronics</option>
                            <option>InformationTechnology</option>
          
                          </select>
                          </label>
                        </div>
                        </label>
          
                    </form>          </td>
                  </tr>
          	        
                  <tr>
                    <td class="bodyText">&nbsp;</td>
                    <td class="bodyText"><form id="form4" name="form4" method="post" action="admin_addfac.php">
                      <label>
          
          			  
                        <div align="left">
                          <input name="Reset" type="reset" id="Reset" value="Reset" /> 
                          <input type="submit" name="Submit" value="Submit" />
                          </div>
                          </label>
          
                    </form>          </td>
                  </tr>
          
                  </table></td>
              <td>&nbsp;</td>
          
            </tr>
          </table>
          <br />
          </body>
          </html>

          Comment

          • RobUK
            New Member
            • Nov 2009
            • 3

            #6
            It seems the problem is that the data is not being submitted to your PHP page. The reason for this is your use of form tags. Typically, a form should look like this:
            <form>
            <input text>
            <input text>
            <input text>
            <input submit>
            </form>

            The submit button will then submit all input fields between the <form></form> tags to the target page. In your case, each input field and the submit button are in their own set of form tags.

            Have a look at your HTML again and update it as necessary.

            Comment

            • Markus
              Recognized Expert Expert
              • Jun 2007
              • 6092

              #7
              See this tutorial on forms & PHP.

              Comment

              • arushibafna
                New Member
                • Nov 2009
                • 8

                #8
                hey,
                thank you...u were right, my html format was wrong. i changed the page to a single form..and got my results..
                but i don't understand why it didn't support multiple forms format?

                Comment

                • RobUK
                  New Member
                  • Nov 2009
                  • 3

                  #9
                  You can use multiple forms, but submitting a form will only submit the form elements that are wrapped in the same form tags as the submit button. In your case, the submit button was in a form of its own, there was nothing for it to submit.

                  Think of it like a paper form. Each set of form tags is one sheet of paper. You can only submit one sheet of paper, and in your case, the signature box (submit button) was on a sheet of paper on its own, basically an empty sheet.

                  Comment

                  • arushibafna
                    New Member
                    • Nov 2009
                    • 8

                    #10
                    hey,
                    thanks a lot..u cleared my doubts...!!

                    Comment

                    Working...