Jump to content

Phantom form submit


Go to solution Solved by akphidelt2007,

Recommended Posts

Having trouble submitting a dynamically generated form.

I am getting no errors on submit, and nothing written to my table, just an indicator that I have landed on my "submit.php".

The form is generated by checkboxes with action="../auditsys/submit.php" the checkbox form is echoed in php with variables as the values ie. $iso40 is the first form etc. which is reflected in the issets below. All the columns in "audit_data" table correspond to the $_POST values and subsequently to the input field "name " attribute.

I can show the html form if requested, i haven't because it's long and embarrassingly messy at the moment.

submit.php:

<?php

ini_set
('display_errors',1);

error_reporting(E_ALL);
echo "landing at form indicator <br>";

$host = "localhost";
$username = "XXX";
$password = "XXX!";
$database = "XXX";

$link = mysqli_connect("$host", "$username", "$password", "$database");

if ($_SERVER['REQUEST_METHOD'] == 'POST') {

if(isset($value, $iso40, $iso42, $iso50, $iso54, $iso55, $iso56, $iso60, $iso70, $iso73, $iso74, $iso75, $iso76, $iso80, $iso84, $iso85)) {

$query = "INSERT INTO audit_data VALUES
('','{$_POST[auditor]}','{$_POST[auditee]}','{$_POST[datum]}','{$_POST[department]}','{$_POST[func]}','{$_POST[proc]}','{$_POST[audit_type]}',
'{$_POST[copy_to]}','{$_POST[comments]}','{$_POST[Q4101]}','{$_POST[Q4102]}','{$_POST[Q4103]}','{$_POST[Q4104]}','{$_POST[Q4105]}','{$_POST[Q4106]}',
'{$_POST[Q4107]}','{$_POST[Q4108]}','{$_POST[Q4109]}','{$_POST[Q4110]}','{$_POST[Q4211]}','{$_POST[Q4212]}','{$_POST[Q4213]}','{$_POST[Q4214]}',
'{$_POST[Q4221]}','{$_POST[Q4222]}','{$_POST[Q4223]}','{$_POST[Q4231]}','{$_POST[Q4232]}','{$_POST[Q4233]}','{$_POST[Q4234]}','{$_POST[Q4235]}',
'{$_POST[Q4236]}','{$_POST[Q4237]}','{$_POST[Q4238]}','{$_POST[Q4239]}','{$_POST[Q4241]}','{$_POST[Q4242]}','{$_POST[Q4243]}','{$_POST[Q4244]}',
'{$_POST[Q4245]}','{$_POST[Q4246]}','{$_POST[Q4247]}','{$_POST[Q4248]}','{$_POST[Q5101]}','{$_POST[Q5102]}','{$_POST[Q5103]}','{$_POST[Q5104]}',
'{$_POST[Q5105]}','{$_POST[Q5201]}','{$_POST[Q5301]}','{$_POST[Q5302]}','{$_POST[Q5303]}','{$_POST[Q5304]}','{$_POST[Q5411]}','{$_POST[Q5312]}',
'{$_POST[Q5313]}','{$_POST[Q5421]}','{$_POST[Q5422]}','{$_POST[Q5423]}','{$_POST[Q5511]}','{$_POST[Q5521]}','{$_POST[Q5522]}','{$_POST[Q5523]}',
'{$_POST[Q5531]}','{$_POST[Q5532]}','{$_POST[Q5611]}','{$_POST[Q5612]}','{$_POST[Q5613]}','{$_POST[Q5621]}','{$_POST[Q5622]}','{$_POST[Q5623]}',
'{$_POST[Q5624]}','{$_POST[Q5625]}','{$_POST[Q5626]}','{$_POST[Q5627]}','{$_POST[Q5631]}','{$_POST[Q5632]}','{$_POST[Q5633]}','{$_POST[Q6101]}',
'{$_POST[Q6102]}','{$_POST[Q6211]}','{$_POST[Q6221]}','{$_POST[Q6222]}','{$_POST[Q6223]}','{$_POST[Q6224]}','{$_POST[Q6225]}','{$_POST[Q6301]}',
'{$_POST[Q6302]}','{$_POST[Q6303]}','{$_POST[Q6401]}','{$_POST[Q7101]}','{$_POST[Q7102]}','{$_POST[Q7103]}','{$_POST[Q7104]}','{$_POST[Q7105]}',
'{$_POST[Q7106]}','{$_POST[Q7201]}','{$_POST[Q7202]}','{$_POST[Q7203]}','{$_POST[Q7204]}','{$_POST[Q7221]}','{$_POST[Q7222]}','{$_POST[Q7223]}',
'{$_POST[Q7224]}','{$_POST[Q7225]}','{$_POST[Q7226]}','{$_POST[Q7231]}','{$_POST[Q7232]}','{$_POST[Q7233]}','{$_POST[Q7311]}','{$_POST[Q7312]}',
'{$_POST[Q7313]}','{$_POST[Q7314]}','{$_POST[Q7315]}','{$_POST[Q7316]}','{$_POST[Q7321]}','{$_POST[Q7322]}','{$_POST[Q7323]}','{$_POST[Q7324]}',
'{$_POST[Q7325]}','{$_POST[Q7326]}','{$_POST[Q7327]}','{$_POST[Q7331]}','{$_POST[Q7332]}','{$_POST[Q7333]}','{$_POST[Q7334]}','{$_POST[Q7335]}',
'{$_POST[Q7336]}','{$_POST[Q7341]}','{$_POST[Q7342]}','{$_POST[Q7343]}','{$_POST[Q7344]}','{$_POST[Q7345]}','{$_POST[Q7351]}','{$_POST[Q7352]}',
'{$_POST[Q7361]}','{$_POST[Q7362]}','{$_POST[Q7363]}','{$_POST[Q7364]}','{$_POST[Q7371]}','{$_POST[Q7372]}','{$_POST[Q7373]}','{$_POST[Q7374]}',
'{$_POST[Q7411]}','{$_POST[Q7412]}','{$_POST[Q7413]}','{$_POST[Q7415]}','{$_POST[Q7421]}','{$_POST[Q7422]}','{$_POST[Q7423]}','{$_POST[Q7424]}',
'{$_POST[Q7431]}','{$_POST[Q7432]}','{$_POST[Q7511]}','{$_POST[Q7512]}','{$_POST[Q7513]}','{$_POST[Q7514]}','{$_POST[Q7515]}','{$_POST[Q7516]}',
'{$_POST[Q7521]}','{$_POST[Q7522]}','{$_POST[Q7523]}','{$_POST[Q7524]}','{$_POST[Q7525]}','{$_POST[Q7526]}','{$_POST[Q7527]}','{$_POST[Q7531]}',
'{$_POST[Q7532]}','{$_POST[Q7533]}','{$_POST[Q7534]}','{$_POST[Q7541]}','{$_POST[Q7542]}','{$_POST[Q7543]}','{$_POST[Q7551]}','{$_POST[Q7552]}',
'{$_POST[Q7553]}','{$_POST[Q7554]}','{$_POST[Q7555]}','{$_POST[Q7556]}','{$_POST[Q7557]}','{$_POST[Q7601]}','{$_POST[Q7602]}','{$_POST[Q7603]}',
'{$_POST[Q7604]}','{$_POST[Q7605]}','{$_POST[Q7606]}','{$_POST[Q7607]}','{$_POST[Q7608]}','{$_POST[Q7609]}','{$_POST[Q7610]}','{$_POST[Q7611]}',
'{$_POST[Q811]}','{$_POST[Q812]}','{$_POST[Q813]}','{$_POST[Q814]}','{$_POST[Q8211]}','{$_POST[Q8211]}','{$_POST[Q8211]}','{$_POST[Q8212]}',
'{$_POST[Q8221]}','{$_POST[Q8222]}','{$_POST[Q8223]}','{$_POST[Q8224]}','{$_POST[Q8225]}','{$_POST[Q8226]}','{$_POST[Q8227]}','{$_POST[Q8228]}',
'{$_POST[Q8229]}','{$_POST[Q8231]}','{$_POST[Q8232]}','{$_POST[Q8233]}','{$_POST[Q8241]}','{$_POST[Q8242]}','{$_POST[Q8243]}','{$_POST[Q8244]}',
'{$_POST[Q8245]}','{$_POST[Q8401]}','{$_POST[Q8402]}','{$_POST[Q8403]}','{$_POST[Q8404]}','{$_POST[Q8405]}','{$_POST[Q8406]}','{$_POST[Q8511]}',
'{$_POST[Q8512]}','{$_POST[Q8521]}','{$_POST[Q8522]}','{$_POST[Q8523]}','{$_POST[Q8524]}','{$_POST[Q8525]}','{$_POST[Q8526]}','{$_POST[Q8527]}',
'{$_POST[Q8528]}','{$_POST[Q8531]}','{$_POST[Q8532]}','{$_POST[Q8533]}','{$_POST[Q8534]}','{$_POST[Q8535]}','{$_POST[Q8536]}','{$_POST[Q8537]}')"
;

echo $query;

mysqli_query($link, $query) or die(mysqli_error($link)." Q=".$query);

print_r($_POST);

// ============ END ============== //

} // if POST > END

mysqli_close($link);
}

?>

I have checked and changed and checked my syntax but to no avail.

Im using textpattern CMS if it's any use.

I used the below to try and get an error code.

Refs: PHP: Simple form to posts to database

Link to comment
https://forums.phpfreaks.com/topic/276152-phantom-form-submit/
Share on other sites

Cheers for reply.

 

Ok decided against it, you would be here all night.

 

Basically, i have a contents form which has checkboxes next to each title. Each checkbox's value is a variable ie. $iso40.

 

Then each variable is set to a form like this:

$iso40 <<<iso40

// a form here

iso40;
 

then i have a foreach loop which displays the variable (form) depending on which checkbox has been checked.

 

Then you fill the form, press submit and it should write to the database :(

Link to comment
https://forums.phpfreaks.com/topic/276152-phantom-form-submit/#findComment-1421031
Share on other sites

Those values have to be explicitly created in the script itself, not from the form. The second the form is submitted you have to create the values. Only the $_POST values are maintained after the form is submitted. So if $query is not echoing than one or a multiple of those values are not set. Unless you skipped most of your code just to show us a short version, those values aren't being created anywhere within the script.

 

Try to echo out $value... guarantee you will get an undefined variable error.

Edited by akphidelt2007
Link to comment
https://forums.phpfreaks.com/topic/276152-phantom-form-submit/#findComment-1421033
Share on other sites

Hi, the $iso40 etc are only html forms, not values i want to input into the database. I only included them to stop getting undefined index errors :S

 

I don't get what you mean by those variables are "html forms". You mean you are saving the html code of a form to that variable within your script? Or are those just names of forms? Just go through each variable at a time and check to see what value you are getting. Most likely none of them are set.

Link to comment
https://forums.phpfreaks.com/topic/276152-phantom-form-submit/#findComment-1421039
Share on other sites

I don't get what you mean by those variables are "html forms". You mean you are saving the html code of a form to that variable within your script? Or are those just names of forms? Just go through each variable at a time and check to see what value you are getting. Most likely none of them are set.

 

Yeah, saving the html form to a variable within the script. They are all set but in a different form which is why i was getting undefined index. i have remed out the isset and now i'm getting undefined constants on all lines.

 

also getting Column count doesn't match value count at row 1

 

Ii will elaborate on what im trying to achieve.

 

I want my client to be able to pick and choose the area of their business they want to audit, so i created a list of checkboxes where they can generate their own audit form which they fillout and submit it to the database. Then they can search on the date and stuff later but haven't got to that yet.

 

I started with multiple tables but couldn't get it to submit each form to its corresponding table so i consolidated into one big table.

 

I think the problem is when they generate the forms they want to complete there are loads of forms which haven't been filled in. Is this a problem or will mysql just accept it as a null value?

 

Thanks for your time so far.

Link to comment
https://forums.phpfreaks.com/topic/276152-phantom-form-submit/#findComment-1421042
Share on other sites

  • Solution

You are getting the column count error because you have not specified any columns.

 

 

$query = "INSERT INTO audit_data (column1,column2,column3,etc,etc,etc,etc) VALUES";

 

The way you have it set up will require a very tedious amount of typing. Not including the fact that you are submitting data that isn't secure. There's way too much to advise on with this. Gonna have to break it down piece by piece to get a hold of what exactly you are doing and make it work.

Link to comment
https://forums.phpfreaks.com/topic/276152-phantom-form-submit/#findComment-1421052
Share on other sites

I don't understand, i have got this to work before in my planning section, the only difference is its a different table and more information from a different form how can it be so complicated? Also, its in an intranet and controlled by radio buttons so no need for security at this point.

Link to comment
https://forums.phpfreaks.com/topic/276152-phantom-form-submit/#findComment-1421117
Share on other sites

This is the code that works, without this working the system wont allow me to generate a header and therefore wont allow me to submit an audit.

 

 

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
 
$query = "INSERT INTO audit_plan VALUES 
('','$_POST[auditor]','$_POST[auditee]','$_POST[datum]','$_POST[department]','$_POST[function]','$_POST[proc]','$_POST[audit_type]','$_POST[copy_to]','$_POST[comments]')";
mysqli_query($link, $query);
}
 
notice the quotes are outside the variable, don't know why this works but it does.
Link to comment
https://forums.phpfreaks.com/topic/276152-phantom-form-submit/#findComment-1421128
Share on other sites

You are getting the column count error because you have not specified any columns.

 

 

$query = "INSERT INTO audit_data (column1,column2,column3,etc,etc,etc,etc) VALUES";

 

The way you have it set up will require a very tedious amount of typing. Not including the fact that you are submitting data that isn't secure. There's way too much to advise on with this. Gonna have to break it down piece by piece to get a hold of what exactly you are doing and make it work.

 

Thanks for you patience, I understand now. its all clicked into place. Took long enough! i have to specify the columns if there is going to be null values otherwise how does mysql know where i want the data? hehe. im sure i will find a better way of doing this, maybe a while loop, but i cant run before i can walk. cheers again!

Link to comment
https://forums.phpfreaks.com/topic/276152-phantom-form-submit/#findComment-1421147
Share on other sites

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.