aztec Posted February 8, 2008 Share Posted February 8, 2008 Hello I am having a problem getting multiple fields posted from a form using PHP into a MYSQL database. The following code will only allow me to input the first field, ie first_name into the database. I do not get any errors and after I click submit the form regenerates but without informing me that a new person as been added. Any help would be appreciated. Kind Regards <?php if (isset($_POST['first_name'])): $dbcnx = @mysql_connect('xxxxxx', 'yyyyyy', 'zzzzzz'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } if (!@mysql_select_db('xxxxxx')) { exit('<p>Unable to locate the xxxxxx ' . 'database at this time.</p>'); } $first_name = $_POST['first_name']; $second_name = $_POST['second_name']; $surname = $_POST['surname']; $sql = "INSERT INTO QQQQQQ SET first_name='$first_name', second_name='$second_name', surname = '$surname'”; <?php else: // Allow the user to enter a new person ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" > <table> <tr> <!--<label>First Name:<input type="varchar" name="first_name" /></label><br />--> <td colspan="2" class="lablecell"><label>First Name</label></td> <td colspan="2" class="fieldcell"> <input type="varchar" name="first_name" /></td> </tr> <tr> <td colspan="2" class="lablecell"><label>Second Name</label></td> <td colspan="2" class="fieldcell"> <input type="varchar" second_name="second_name" /></td> </tr> <tr> <td colspan="2" class="lablecell"><label>Surname</label></td> <td colspan="2" class="fieldcell"> <input type="varchar" surname="surname" /></td> </tr> <tr> <td colspan="2"><input type="submit" name="Submit" value="Submit" /></td> </tr> </table> </form> <?php endif; ?> Quote Link to comment Share on other sites More sharing options...
fenway Posted February 8, 2008 Share Posted February 8, 2008 Are you sure your POST hash is "full"? Quote Link to comment Share on other sites More sharing options...
aztec Posted February 8, 2008 Author Share Posted February 8, 2008 Hello Fenway I do not know if it full or not. I am assuming that it contains all of the data fields. How can I test it please. Regards Quote Link to comment Share on other sites More sharing options...
fenway Posted February 8, 2008 Share Posted February 8, 2008 First, echo the $sql variable, let's make sure it makes sense. Second, that's a PHP question... I have no idea. Quote Link to comment Share on other sites More sharing options...
aztec Posted February 8, 2008 Author Share Posted February 8, 2008 Hello Fenway It echos out with data only in the first field ie first_name, then lists all the other fields without any data in them. Regards Quote Link to comment Share on other sites More sharing options...
fenway Posted February 8, 2008 Share Posted February 8, 2008 Well, I can't see it... but it's solved now? How? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.