Situation::
I use PHP to connect to the MySQL database and insert some kind of demographic form generated by the variables, and some scoring results generate the calculated variables.
The generated variables of the demographic "form" are located correctly * ... but the results of the calculation of the results generated by the calculated variables are not * . However, in an email that is automatically sent to the user when the form is submitted, these scoring results generated by the calculated variables are sent and calculated correctly, and both types of variables are displayed in an echo or printed splash screen.
The form, by the way, is a survey of satisfaction with 15 questions on each question with 7 options (switch), and each option costs a different number of points.
I worked on this for 5 days, read all the topics related to this topic on this website, tried many different configurations, but without success and could not find a way to insert these last 7 variable values ββ(skill_variety, task_identity, task_significant, autonomy , feed_back, total, MPS) to the MYSQL database.
I use hidden input to insert the results of counting the results calculated but failed
<FORM METHOD=POST action="<?php echo $_SERVER['PHP_SELF']; ?>" NAME="action" id="action" onSubmit="return validate(this);"> <input type="hidden" name="action" value="true"> <input type="hidden" name="skill_variety" id="skill_variety" value="<?php echo $_POST['skill_variety'] ?>" /> <input type="hidden" name="task_variety" id="task_variety" value="<?php echo $_POST['task_variety'] ?>" />
If more code is required, I will be happy to add it. Just let me know.
I know that you help, and are also upset by such questions many times, but I hope you can offer professional advertising and some suggestions. I already have thin hair and hope not to pull out the rest before the scheduled time.
My need
Some direction / suggestion / solution for obtaining these disobedient variables (skill_variety, task_identity, task_significant, autonomy, feed_back, total, MPS) is inserted into the MYSQL target table.
Thanks in advance for any direction and I hope that I was clear and ready in this post.
BTW is testing the URL here if it helps to see the situation "en vivo" http://www.marscafe.com/php/hr2/master_9.php
Database configured here
CREATE TABLE IF NOT EXISTS mydb3 ( id int(11) NOT NULL AUTO_INCREMENT, s varchar(60), name varchar(50), email varchar(50), ordered varchar(4), optype varchar(50), rate varchar(50), time timestamp not null default now(), skill_variety varchar(8), task_identity varchar(8), task_significant varchar(8), autonomy varchar(8), feed_back varchar(8), total varchar(8), MPS varchar(12), PRIMARY KEY (id) ) ENGINE=MyISAM
Here is the INSERT and CONNECT PHP CODES code
<?php //MySQL Database Connect include '../../../../phpinc.php'; // Only process the form if $_POST isn't empty if ( ! empty( $_POST ) ) { // Connect to MySQL variables are defined in the include file $mysqli = new mysqli($hostname, $username, $password, $dbName ); // Check the connection if ( $mysqli->connect_error ) { die( 'Connect Error: ' . $mysqli->connect_errno . ': ' . $mysqli->connect_error ); } // Insert the data $sql = "INSERT INTO `mydb3` ( name, email, ordered, optype, rate, skill_variety, task_identity, task_significant, autonomy, feed_back, total, MPS ) VALUES ( '{$mysqli->real_escape_string($_POST['name'])}', '{$mysqli->real_escape_string($_POST['email'])}', '{$mysqli->real_escape_string($_POST['ordered'])}', '{$mysqli->real_escape_string($_POST['optype'])}', '{$mysqli->real_escape_string($_POST['rate'])}', '{$mysqli->real_escape_string($_POST['skill_variety'])}', '{$mysqli->real_escape_string($_POST['task_identity'])}', '{$mysqli->real_escape_string($_POST['task_significant'])}', '{$mysqli->real_escape_string($_POST['autonomy'])}', '{$mysqli->real_escape_string($_POST['feed_back'])}', '{$mysqli->real_escape_string($_POST['total'])}', '{$mysqli->real_escape_string($_POST['Motivating_Potential_Score'])}' )"; $insert = $mysqli->query($sql); echo $sql; // Print response from MySQL if ( $insert ) { print("<br>"); echo "Success! Row ID: {$mysqli->insert_id}"; } else { die("Error: {$mysqli->errno} : {$mysqli->error}"); } ## #$mysqli->close(); has been moved from here to after the automated email code ?>
Here's what happens as printed on the splash screen using echo $ sql;
INSERT INTO mydb3 (name, email, ordered, optype, rate, skill_variety, task_identity, task_significant, autonomy, feed_back, total, MPS) VALUES ( 'Jack White', ' mars@marscafe.com ','NO', 'Other','Other', '','', '','', '','','' ) Success! Row ID: 46 skill_variety
Here's what happens as printed on the splash screen using
echo "<pre>"; print_r($_POST); echo "</pre>"; Array ( [action] => true [skill_variety] => [task_variety] => [name] => Jack White [email] => mars@marscafe.com [rate] => Other [ordered] => NO [optype] => Other [question-1-answers] => E [question-2-answers] => F [question-3-answers] => B [question-4-answers] => C [question-5-answers] => A [question-6-answers] => G [question-7-answers] => G [question-8-answers] => G [question-9-answers] => G [question-10-answers] => D [question-11-answers] => D [question-12-answers] => D [question-13-answers] => D [question-14-answers] => D [question-15-answers] => D )