SentiJB Posted April 11, 2021 Share Posted April 11, 2021 im a bit struggling to get something working want to add an extra field in the review page so in content.product.php i add : <p> <label for="rev_bijkomend">bijkomende opmerking</label> <input id="rev_bijkomend" type="text" name="bijkomend" value="{$WRITE.bijkomend}" class="textbox" /> </p> in cubecart.class.php after $record['rating'] = (isset($_POST['rating'])) ? $_POST['rating'] : 0; $record['product_id'] = (int)$_GET['product_id']; $record['ip_address'] = get_ip_address(); $record['time'] = time(); i add $record['bijkomend'] = (isset($_POST['bijkomend'])); in database i added the new table bijkomend set as text utf8_unicode_ci but whatever i do , it doesn't store the field bijkomend in the database. What am i doing wrong ? Link to comment Share on other sites More sharing options...
bsmither Posted April 11, 2021 Share Posted April 11, 2021 Let's review: $record['bijkomend'] = (isset($_POST['bijkomend'])); The form element with the input name "bijkomend" will get POSTed if the input tag is within the appropriate <form> block. The statement above tests if the form element exists in the POSTed data. But, so far, the answer is either a 'true' or a 'false' logical value. This is the start of a typical test structure called a Tertiary Operator. We can see that with the $_POST['rating']. To finish that statement: $record['bijkomend'] = (isset($_POST['bijkomend'])) ? $_POST['bijkomend'] : ''; The $record array will be saved in the CubeCart_reviews database table, so the new column 'bijkomend' should have been added to that table. Link to comment Share on other sites More sharing options...
SentiJB Posted April 11, 2021 Author Share Posted April 11, 2021 thank you , that works. still learning i tried a lot of things. and something i really dont understand... when you look at the form to submit the review , you have the title and review box but it you look at the functions to add it in the database , nothing there to find for those boxes. Link to comment Share on other sites More sharing options...
bsmither Posted April 11, 2021 Share Posted April 11, 2021 CubeCart takes a shortcut. Let's look at the private function _product() in the cubecart.class.php file. About twelve lines in, the entirety of the $_POST['review'] array is passed to $record (after encoding all the special characters). The $_POST['review'] array includes: 'anon' or 'name' and 'email', 'title', 'review'. Now, $record has those array elements. The code that actually does the database insertion checks to make sure that there is a table column having the same name as the array element key. Thus, the value in $record['title'] will end up in the 'title' column of the row being inserted. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.