Jump to content

Recommended Posts

I have a form with a table that contains ONLY dropdown menus for users to select quantities from 25 dinner items.  It contains some Javascript, but nothing fancy.  In an effort to establish my database and TEST to see how some PHP functions might respond so I could improve my form, I created a mini version of the db in MySQL.

 

But when I click the submit button, the page blinks, the address bar fills with field names, but there is no connect.  No error messages.  No data transfer.  NO NOTHING!

 

I searched the web and copied a form and plugged it in (an html form, a php insert file, and a MySQL database) and it worked fine.  I peared down my page to mirror it, and still, no success.

 

What little detail am I missing??  If I have 25 fields but create a db for the first 6, should it function?

If I reduce it and try to re-use the same db, am I persuing a problem?

I've tried error trapping and changing the form inputs, but it just still doesn't connect.

 

Please help!

Link to comment
https://forums.phpfreaks.com/topic/257500-am-i-missing-a-minor-detail/
Share on other sites

The HTML looks something like this all the way throuogh:

<tr><td>

      <select name="brisket">

        <option value="0.00" selected>  --- </option>

        <option value="1.00">  1  </option>

        <option value="2.00">  2  </option>

        <option value="3.00">  3  </option>

        <option value="4.00">  4  </option>

        <option value="5.00">  5  </option>

        <option value="6.00">  6  </option>

        <option value="7.00">  7  </option>

        <option value="8.00">  8  </option>

        <option value="9.00">  9  </option>

        <option value="10.00">10  </option>

      </select></td><td>BRISKET OF BEEF</td><td>32.00 LB</td><td>ujiujjpooj</td><td> <!-- FILLER --> </td>

      <td>

      <select name="carrots">

        <option value="0.00" selected>  --- </option>

        <option value="1.00">  1  </option>

        <option value="2.00">  2  </option>

        <option value="3.00">  3  </option>

        <option value="4.00">  4  </option>

        <option value="5.00">  5  </option>

        <option value="6.00">  6  </option>

        <option value="7.00">  7  </option>

        <option value="8.00">  8  </option>

        <option value="9.00">  9  </option>

        <option value="10.00">10  </option>

      </select></td><td>CARROTS</td><td>

 

and my PHP is here:

 

<?php   

require('connection.php');

 

mysql_connect("$hostname", "$username", "$password") or die ('Unable to connect to database!);

mysql_select_db("$database") or die('Could not connect to db: ' . mysql_error());

 

if(isset($_POST['action']) && $_POST['action'] == 'submitform')

{

$roastturkey = $_POST['roastturkey'];

$broccoli = $_POST['broccoli'];

$brisket = $_POST['brisket'];

$carrots = $_POST['carrots'];

$EZchix_sum= $_POST['EZchix_sum'];

$chixcutlet = $_POST['chixcutlet'];

$chixfingers = $_POST['chixfingers'];

$strgbalmond_sum=$_POST['strgbalmond_sum'];

$strgbalmond1 = $_POST['strgbalmond1'];

$strgbalmond2 = $_POST['strgbalmond2'];

$strgbalmond3 = $_POST['strgbalmond3'];

}

 

$sql = "INSERT INTO dinnertable (roastturkey,broccoli,brisket,carrots,chixcutlet,chixfingers,strgbalmond1,strgbalmond2,strgbalmond3) VALUES

('','$roastturkey','$broccoli','$brisket','$carrots','$chixcutlet','$chixfingers','$strgbalmond1','$strgbalmond2','$strgbalmond3')";

 

$result=mysql_query($sql);

// if successfully insert data into database, displays message "Successful".

if($result){

echo "Successful";

else {

echo "ERROR";

}

>

 

I just noticed that the feature for the TOTAL chicken and strgbalmond were being carried in the address bar.  They are not important for my database, but maybe i needfields for them anyway????

 

Anditionally, I created a simple form with one field and a submit and ran it through my insert script and I got a successful connection and error message.  Then I re-wrote my button on this form, and still no connection.

 

Is the something about HTML 'selects' that I'm missing?  Or a PHP comma or quote??

 

Also you fields/values count is off..

$sql = "INSERT INTO dinnertable (roastturkey,broccoli,brisket,carrots,chixcutlet,chixfingers,strgbalmond1,strgbalmond2,strgbalmond3) VALUES
('','$roastturkey','$broccoli','$brisket','$carrots','$chixcutlet','$chixfingers','$strgbalmond1','$strgbalmond2','$strgbalmond3')";

9 fields vs 10 values

IF first field is an auto increment field no need to list it in the values

 

 

My form begins with:

<form name="orderpage" action="passpost.php" method="post">

<table>

 

OOPS!!! never mind.  Now I feel stupid.  Been staring at this for 6 hours, and when I cut and pasted the code I noticed I had 2 form tags, so the submit was actually outside the process.  Now I'm fine.

 

This is why I'm just a PUP (or PUPIL) at this point.  Sometimes you just need a second set of eyes to see it!

 

Thanks for the assist.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.