laticca8 Posted April 4, 2007 Share Posted April 4, 2007 Hello, all. I have a form with radio buttons. I typically don't use them and thought I would take the time to figure them out this time. The values won't post to the database. Please let me know what I'm doing wrong here. The joint field is a yes/no question with 2 radio buttons: My form has this code: <table border="0" width="100%" id="table13"> <tr> <td>Is this a joint application (more than one borrower)?</td> <td> <input id="j1" type="radio" value="yes" name="joint" tabindex="2"> Yes <input id="j2" type="radio" value="no" name="joint"> No</td> </tr> </table> My action file has this code (upon user clicking submit): <?php if ($_POST["sent"] == "Submit") { $DBhost = "localhost"; $DBuser = "user"; $DBpass = "pwod"; $DBName = "test"; $table = "apply"; $id = $_POST['id']; $referral=$_POST['referral']; $joint=array('yes','no'); $joint=$_POST['joint']; mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database"); @mysql_select_db("$DBName") or die("Unable to select database $DBName"); $sqlquery = "INSERT INTO $table VALUES('$id','$referral','$joint',NOW())"; $results = mysql_query($sqlquery); mysql_close(); } ?> My SQL table has the following fields: id referral joint date Thanks for your help! Quote Link to comment Share on other sites More sharing options...
btherl Posted April 4, 2007 Share Posted April 4, 2007 Did you forget to include your form tags and your submit button when you posted, or are they missing altogether? The other thing you should do is check mysql_query() for errors. $results = mysql_query($sqlquery) or die("Query failed: $sqlquery\n" . mysql_error()); Quote Link to comment Share on other sites More sharing options...
laticca8 Posted April 4, 2007 Author Share Posted April 4, 2007 thanks for your response. yes, if have the form tag and submit. i've done forms several times in php, but i always avoided radio buttons because of the headache. i may just have to change them over to the checkbox. there are just so many of them that i would rather figure out how to fix it. ok, i'll add the error check. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 4, 2007 Share Posted April 4, 2007 Add this line to the start of your processing script: <?php if (isset($_POST['sent'])) echo '<pre>' . print_r($_POST,true) . '</pre>'; ?> and post what is displayed between tags. Ken Quote Link to comment Share on other sites More sharing options...
laticca8 Posted April 4, 2007 Author Share Posted April 4, 2007 sorry, ken. that didn't work. when i click "submit," a blank page pops up and there are no new rows in the database. 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.