Lambneck Posted August 27, 2008 Share Posted August 27, 2008 Having trouble storing form info to database. here is the form: <form name="Jobs" Method="POST"> <table id="table1" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <tr> <td> <u>SELECT THE LOCATION OF YOUR SCHOOL:</u> </td> </tr> <tr> <td> <INPUT TYPE="radio" Name="country" VALUE="China">China<br> <INPUT TYPE="radio" Name="country" VALUE="Japan">Japan<br> <INPUT TYPE="radio" Name="country" VALUE="Korea">Korea<br> <INPUT TYPE="radio" Name="country" VALUE="Thailand">Thailand<br> <INPUT TYPE="radio" Name="country" VALUE="Other">Other<br> <br><br> </td> </tr> <tr> <td> <u>COMPANY INFORMATION</u> </td> </tr> <tr> <td> Company Name: </td> </tr> <tr> <td> <INPUT TYPE="text" NAME="company_name" SIZE=30> <br><br> </td> </tr> <tr> <td> Address: </td> </tr> <tr> <td> <TEXTAREA NAME="company_address" COLS=30 ROWS=3></textarea> <br><br> </td> </tr> <br><br> <tr> <td> <u>YOUR INFORMATION</u> </td> </tr> <tr> <td> Name as it appears on your credit card: </td> </tr> <tr> <td> <INPUT TYPE="text" NAME="billing_name" SIZE=30> <br><br> </td> </tr> <tr> <td> Credit card billing address: </td> </tr> <tr> <td> <INPUT TYPE="text" NAME="billing_address" SIZE=30> <br><br> </td> </tr> <tr> <td> Phone number: </td> </tr> <tr> <td> <INPUT TYPE="text" NAME="phone_number" SIZE=30> <br><br> </td> </tr> <tr> <td> E-Mail address: </td> </tr> <tr> <td> <INPUT TYPE="text" NAME="email" SIZE=30> <br><br> </td> </tr> <br><br> <tr> <td> <u>CREDIT CARD INFORMATION</u> </td> </tr> <tr> <td> Credit card number: </td> </tr> <tr> <td> <INPUT TYPE="text" NAME="card_number" SIZE=30> <br><br> </td> </tr> <tr> <td> Credit card type: </td> </tr> <tr> <td> <INPUT TYPE="radio" Name="cardtype" VALUE="Mastercard">Mastercard<br> <INPUT TYPE="radio" Name="cardtype" VALUE="Visa">Visa<br> <br> </td> </tr> <tr> <td> Expiration date: </td> </tr> <tr> <td> <INPUT TYPE="text" NAME="card_expiration" SIZE=30><font face="Times New Roman">MM/YY</font> <br><br> </td> </tr> <tr> <td> Special Instructions: </td> </tr> <tr> <td> <TEXTAREA NAME="special_instructions" COLS=30 ROWS=3></textarea> <br><br> </td> </tr> <tr> <td> <i>If there are any billing problems or questions about your ad, we will contact you.</i> <br> <br> </td> </tr> <tr> <td> <u>JOB LISTING</u> <br> (This is your actual ad. Please enter all appropriate information.) <br> </td> </tr> <tr> <td> Job location: </td> </tr> <tr> <td> <INPUT TYPE="text" NAME="subject" SIZE=50> <br><br> </td> </tr> <tr> <td> Job listing, including contact information: </td> </tr> <tr> <td> <TEXTAREA NAME="message" COLS=100 ROWS=20></TEXTAREA> <br><br> </td> </tr> <br> <tr> <td> <INPUT TYPE="Submit" VALUE="Submit Message" Name="submit"> <INPUT TYPE="Reset" VALUE="Reset Message" Name="reset"> <br><br> </td> </tr> </table> </form> and here is the php: mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($database); if (isset($_POST['Submit'])) { $country = $_POST['country']; $compname = $_POST['company_name']; $compadd = $_POST['company_address']; $billname = $_POST['billing_name']; $billadd = $_POST['billing_address']; $phone = $_POST['phone_number']; $email = $_POST['email']; $cardnum = $_POST['card_number']; $cardtype = $_POST['cardtype']; $cardexp = $_POST['card_expiration']; $instructions = $_POST['special_instructions']; $subject = $_POST['subject']; $message = $_POST['message']; $submission_date = date("l M dS, Y, H:i:s"); $ip = getenv ('REMOTE_ADDR'); mysql_query("INSERT INTO $table (col_1, col_2, col_3, col_4, col_5, col_6, col_7, col_8, col_9, col_10, col_11, col_12, col_13, col_14, submission_date, ip_address) VALUES ('country', '$compname', '$compadd', '$billname', '$billadd','$phone','$email','$cardnum','$cardtype','$cardexp','$instructions','$subject','$message', '$submission_date','$ip')")or die(mysql_error()); echo '<table id=table1><tr><td><b>Thank you, your information was was submitted.</b></td></tr>'; the database and table are predefined, if you see any errors in the script please help. also if you know how i might produce an error message that could clue me into what might be the problem please enlighten me what it is and where to put it. right now when the submit button is hit the page just refreshes, with no responses, errors messages, or change other than the form being cleared. any help is greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/121574-solved-having-trouble-new-b/ Share on other sites More sharing options...
Mchl Posted August 27, 2008 Share Posted August 27, 2008 Do you have error reporting enabled? You might want to put ini_set('error_reporting', E_ALL); As the first line of your PHP script. And you have no action specified for the form in your HTML code Quote Link to comment https://forums.phpfreaks.com/topic/121574-solved-having-trouble-new-b/#findComment-627043 Share on other sites More sharing options...
Lambneck Posted August 27, 2008 Author Share Posted August 27, 2008 Thanks Mchl. I inserted the ini_set into the first line of php script, but still no change... Quote Link to comment https://forums.phpfreaks.com/topic/121574-solved-having-trouble-new-b/#findComment-627077 Share on other sites More sharing options...
Mchl Posted August 27, 2008 Share Posted August 27, 2008 Your form has no action defined, so it doesn't know what file to run http://www.w3schools.com/tags/tag_form.asp Quote Link to comment https://forums.phpfreaks.com/topic/121574-solved-having-trouble-new-b/#findComment-627085 Share on other sites More sharing options...
wildteen88 Posted August 27, 2008 Share Posted August 27, 2008 Where is your form supposed to submit to, for processing? As currently your form does not have an action. Without the action your form will just submit to itself (reloading the page). Quote Link to comment https://forums.phpfreaks.com/topic/121574-solved-having-trouble-new-b/#findComment-627087 Share on other sites More sharing options...
Lambneck Posted August 27, 2008 Author Share Posted August 27, 2008 well as it is the form would submit to a mysql database, the page wouldn't change but the echo would respond to the user. Quote Link to comment https://forums.phpfreaks.com/topic/121574-solved-having-trouble-new-b/#findComment-627107 Share on other sites More sharing options...
wildteen88 Posted August 27, 2008 Share Posted August 27, 2008 The form has to submit to php script for processing you cant submit a form directly to a database. I presume your HTML and PHP code are in the same file? Quote Link to comment https://forums.phpfreaks.com/topic/121574-solved-having-trouble-new-b/#findComment-627112 Share on other sites More sharing options...
Ken2k7 Posted August 27, 2008 Share Posted August 27, 2008 Or use AJAX Quote Link to comment https://forums.phpfreaks.com/topic/121574-solved-having-trouble-new-b/#findComment-627118 Share on other sites More sharing options...
Lambneck Posted August 27, 2008 Author Share Posted August 27, 2008 yes they are in the same file Quote Link to comment https://forums.phpfreaks.com/topic/121574-solved-having-trouble-new-b/#findComment-627121 Share on other sites More sharing options...
Ken2k7 Posted August 27, 2008 Share Posted August 27, 2008 2 things: 1. Make sure $db_host, $db_user, $db_pwd and $database are defined. 2. Change this line: if (isset($_POST['Submit'])) To: if (isset($_POST['submit'])) Quote Link to comment https://forums.phpfreaks.com/topic/121574-solved-having-trouble-new-b/#findComment-627129 Share on other sites More sharing options...
Lambneck Posted August 27, 2008 Author Share Posted August 27, 2008 Ken2k7, I made your suggested changes, and received the following message: Column count doesn't match value count at row 1 Quote Link to comment https://forums.phpfreaks.com/topic/121574-solved-having-trouble-new-b/#findComment-627144 Share on other sites More sharing options...
wildteen88 Posted August 27, 2008 Share Posted August 27, 2008 Ken2k7, I made your suggested changes, and received the following message: Column count doesn't match value count at row 1 Your query has 16 columns listed but only 15 values. Quote Link to comment https://forums.phpfreaks.com/topic/121574-solved-having-trouble-new-b/#findComment-627151 Share on other sites More sharing options...
Lambneck Posted August 27, 2008 Author Share Posted August 27, 2008 ok i adjusted that column count and it works now! thank you!! Quote Link to comment https://forums.phpfreaks.com/topic/121574-solved-having-trouble-new-b/#findComment-627163 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.